Skip to content

Commit b7fd22e

Browse files
committed
Update "Introduction" pages in docs
1 parent df25b1b commit b7fd22e

11 files changed

Lines changed: 471 additions & 157 deletions

File tree

.vitepress/config.mts

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ gtag('config', 'G-VYGDN3X0PR');`],
5959
],
6060
themeConfig: {
6161
nav: [
62-
{ text: 'Docs', link: '/docs/getting-started' },
62+
{ text: 'Docs', link: '/docs/getting-started.md' },
6363
{ text: 'Blog', link: '/blog/' },
6464
],
6565
editLink: {
@@ -71,33 +71,35 @@ gtag('config', 'G-VYGDN3X0PR');`],
7171
{
7272
text: 'Introduction',
7373
items: [
74-
{ text: 'Why Testo?', link: '/docs/why-testo' },
75-
{ text: 'Getting Started', link: '/docs/getting-started' },
76-
{ text: 'Configuration', link: '/docs/configuration' },
74+
{ text: 'Why Testo?', link: '/docs/why-testo.md' },
75+
{ text: 'Getting Started', link: '/docs/getting-started.md' },
76+
{ text: 'Configuration', link: '/docs/configuration.md' },
77+
{ text: 'Writing Tests', link: '/docs/writing-tests.md' },
7778
],
7879
},
7980
{
80-
text: 'Writing Tests',
81-
link: '/docs/writing-tests',
81+
text: 'Plugins',
82+
link: '/docs/plugins.md',
8283
items: [
83-
{ text: 'Test Attribute', link: '/docs/plugins/test' },
84-
{ text: 'Naming Conventions', link: '/docs/plugins/convention' },
85-
{ text: 'Inline Tests', link: '/docs/plugins/inline' },
86-
{ text: 'Data Providers', link: '/docs/plugins/data' },
87-
{ text: 'Lifecycle', link: '/docs/plugins/lifecycle' },
84+
{ text: 'Test Attribute', link: '/docs/plugins/test.md' },
85+
{ text: 'Naming Conventions', link: '/docs/plugins/convention.md' },
86+
{ text: 'Inline Tests', link: '/docs/plugins/inline.md' },
87+
{ text: 'Data Providers', link: '/docs/plugins/data.md' },
88+
{ text: 'Lifecycle', link: '/docs/plugins/lifecycle.md' },
89+
{ text: 'Retry', link: '/docs/plugins/retry.md' },
8890
],
8991
},
9092
{
9193
text: 'Guide',
9294
items: [
93-
{ text: 'CLI Reference', link: '/docs/cli-reference' },
94-
{ text: 'Filtering', link: '/docs/plugins/filter' },
95+
{ text: 'CLI Reference', link: '/docs/cli-reference.md' },
96+
{ text: 'Filtering', link: '/docs/plugins/filter.md' },
9597
],
9698
},
9799
{
98100
text: 'Customization',
99101
items: [
100-
{ text: 'Events', link: '/docs/events' },
102+
{ text: 'Events', link: '/docs/events.md' },
101103
],
102104
},
103105
],
@@ -113,7 +115,7 @@ gtag('config', 'G-VYGDN3X0PR');`],
113115
],
114116
themeConfig: {
115117
nav: [
116-
{ text: 'Документация', link: '/ru/docs/getting-started' },
118+
{ text: 'Документация', link: '/ru/docs/getting-started.md' },
117119
{ text: 'Блог', link: '/ru/blog/' },
118120
],
119121
editLink: {
@@ -125,33 +127,35 @@ gtag('config', 'G-VYGDN3X0PR');`],
125127
{
126128
text: 'Введение',
127129
items: [
128-
{ text: 'Почему Testo?', link: '/ru/docs/why-testo' },
129-
{ text: 'Начало работы', link: '/ru/docs/getting-started' },
130-
{ text: 'Конфигурация', link: '/ru/docs/configuration' },
130+
{ text: 'Почему Testo?', link: '/ru/docs/why-testo.md' },
131+
{ text: 'Начало работы', link: '/ru/docs/getting-started.md' },
132+
{ text: 'Конфигурация', link: '/ru/docs/configuration.md' },
133+
{ text: 'Пишем тесты', link: '/ru/docs/writing-tests.md' },
131134
],
132135
},
133136
{
134-
text: 'Пишем тесты',
135-
link: '/ru/docs/writing-tests',
137+
text: 'Плагины',
138+
link: '/ru/docs/plugins.md',
136139
items: [
137-
{ text: 'Атрибут Test', link: '/ru/docs/plugins/test' },
138-
{ text: 'Конвенции именования', link: '/ru/docs/plugins/convention' },
139-
{ text: 'Встроенные тесты', link: '/ru/docs/plugins/inline' },
140-
{ text: 'Провайдеры данных', link: '/ru/docs/plugins/data' },
141-
{ text: 'Жизненный цикл', link: '/ru/docs/plugins/lifecycle' },
140+
{ text: 'Атрибут \#[Test]', link: '/ru/docs/plugins/test.md' },
141+
{ text: 'Конвенции именования', link: '/ru/docs/plugins/convention.md' },
142+
{ text: 'Встроенные тесты', link: '/ru/docs/plugins/inline.md' },
143+
{ text: 'Провайдеры данных', link: '/ru/docs/plugins/data.md' },
144+
{ text: 'Жизненный цикл', link: '/ru/docs/plugins/lifecycle.md' },
145+
{ text: 'Retry', link: '/ru/docs/plugins/retry.md' },
142146
],
143147
},
144148
{
145149
text: 'Руководство',
146150
items: [
147-
{ text: 'CLI справка', link: '/ru/docs/cli-reference' },
148-
{ text: 'Фильтрация', link: '/ru/docs/plugins/filter' },
151+
{ text: 'CLI справка', link: '/ru/docs/cli-reference.md' },
152+
{ text: 'Фильтрация', link: '/ru/docs/plugins/filter.md' },
149153
],
150154
},
151155
{
152156
text: 'Кастомизация',
153157
items: [
154-
{ text: 'События', link: '/ru/docs/events' },
158+
{ text: 'События', link: '/ru/docs/events.md' },
155159
],
156160
},
157161
],

docs/configuration.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
By default, if no configuration file is provided, Testo will run tests from the `tests` folder with the default plugin set.
44

5-
To customize the configuration, create a `testo.php` file in the root of your project. The file must return an `ApplicationConfig` instance:
5+
To configure Testo, create a `testo.php` file in the root of your project. The file must return an `ApplicationConfig` instance:
66

77
```php
88
<?php
@@ -16,7 +16,6 @@ return new ApplicationConfig(
1616
suites: [
1717
new SuiteConfig(
1818
name: 'Unit',
19-
parallel: true,
2019
location: ['tests/Unit'],
2120
),
2221
new SuiteConfig(
@@ -32,7 +31,6 @@ return new ApplicationConfig(
3231
The root configuration object:
3332

3433
- `suites` — array of Test Suites. Must contain at least one element — an empty array will cause an error.
35-
- `src` — location of the project source code. Will be used for code coverage in the future.
3634
- `plugins` — application-level plugins. Loaded before Test Suites and act globally (see [Plugins](#plugins) section).
3735

3836
All parameters and their default values are described in the class itself — your IDE will show hints.
@@ -60,7 +58,7 @@ new SuiteConfig(
6058
),
6159
```
6260

63-
::: tip
61+
::: info
6462
Arrays in `location` and `plugins` are shorthands for `new FinderConfig(include: ...)` and `SuitePlugins::with(...)`. For more flexible configuration, use `FinderConfig` and `SuitePlugins` directly.
6563
:::
6664

@@ -89,15 +87,22 @@ Testo is built on [plugins](plugins.md) — they define how tests are discovered
8987
If the `plugins` array is not specified, Testo uses the default plugin set.
9088

9189
::: question Which application plugins are enabled by default?
92-
- [FilterPlugin](plugins/filter.md)
93-
- TerminalPlugin
94-
- TeamcityPlugin
90+
You can check the default plugin list in the `ApplicationPlugins` class.
91+
92+
Currently:
93+
- [Filter](plugins/filter.md)
94+
- **Terminal** and **Teamcity** depending on the `--teamcity` flag
9595
:::
9696

9797
::: question Which Test Suite plugins are enabled by default?
98-
- [LifecyclePlugin](plugins/lifecycle.md)
99-
- [InlineTestPlugin](plugins/inline.md)
100-
- [BenchmarkPlugin](plugins/bench.md)
98+
You can check the default plugin list in the `SuitePlugins` class.
99+
100+
Currently:
101+
- [Assert](plugins/assert.md)
102+
- [Bench](plugins/bench.md)
103+
- [Inline](plugins/inline.md)
104+
- [Lifecycle](plugins/lifecycle.md)
105+
- [Test](plugins/test.md)
101106
:::
102107

103108
### Managing Plugins

docs/getting-started.md

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2+
faqLevel: 2
23
llms_description: "Installation via Composer, testo.php configuration, writing first test class, running tests, IDE plugin setup"
34
---
45

56
# Getting Started
67

7-
88
## Installation
99

1010
Install Testo via Composer:
@@ -24,7 +24,7 @@ composer require --dev testo/testo
2424

2525
By default, if no configuration file is provided, Testo will run tests from the `tests` folder.
2626

27-
To customize the configuration, create a `testo.php` file in the root of your project:
27+
To configure Testo, create a `testo.php` file in the root of your project:
2828

2929
```php
3030
<?php
@@ -39,19 +39,11 @@ return new ApplicationConfig(
3939
suites: [
4040
new SuiteConfig(
4141
name: 'Unit',
42-
location: new FinderConfig(
43-
include: ['tests/Unit'],
44-
),
42+
location: ['tests/Unit'],
4543
),
4644
new SuiteConfig(
4745
name: 'Sources',
48-
location: new FinderConfig(
49-
include: ['src'],
50-
),
51-
plugins: SuitePlugins::only(
52-
new InlineTestPlugin(),
53-
new BenchmarkPlugin(),
54-
),
46+
location: ['src'],
5547
),
5648
],
5749
);
@@ -63,54 +55,49 @@ To learn more about configuration, visit the [Configuration](configuration.md) s
6355

6456
## Writing Your First Test
6557

66-
Create a test class in the configured test directory (e.g., `tests/Unit/CalculatorTest.php`):
58+
Create a test class in the configured directory (e.g., `tests/Unit/MyFirstTest.php`) and add a method with the `#[Test]` attribute:
6759

6860
```php
69-
<?php
70-
71-
declare(strict_types=1);
72-
73-
namespace Tests\Unit;
74-
75-
use Testo\Assert;
76-
use Testo\Assert\ExpectException;
77-
use Testo\Application\Attribute\Test;
78-
use Testo\Retry\RetryPolicy;
79-
80-
final class CalculatorTest
61+
final class MyFirstTest
8162
{
8263
#[Test]
8364
public function dividesNumbers(): void
8465
{
8566
$result = 10 / 2;
8667

87-
Assert::same(5.0, $result);
88-
Assert::notSame(5, $result); // Types matter!
68+
Assert::same($result, 5.0);
69+
Assert::notSame($result, 5); // Types matter
8970
}
71+
}
72+
```
9073

91-
#[Test]
92-
#[RetryPolicy(maxAttempts: 3)] // Retries up to 3 times if test fails
93-
public function flakyApiCall(): void
94-
{
95-
$response = $this->makeExternalApiCall();
74+
The `#[Test]` attribute marks the method as a test, and the `Assert` facade checks assertions.
75+
Testo supports a wide range of assertions via `Assert` and expectations via `Expect`.
76+
77+
Use attributes to extend test functionality.
78+
For example, `#[Retry]` retries a test on failure, and `#[ExpectException]` expects a specific exception:
9679

97-
Assert::same(200, $response->status);
80+
```php
81+
#[Test]
82+
final class MyFirstTest
83+
{
84+
#[Retry(maxAttempts: 5)] // Retries up to 5 times if test fails
85+
public function flakyTest(): void
86+
{
87+
Assert::same(mt_rand(0, 2), 2);
9888
}
9989

100-
#[Test]
10190
#[ExpectException(\RuntimeException::class)]
102-
public function throwsException(): void
91+
public function throwsException(): never
10392
{
10493
throw new \RuntimeException('Expected error');
10594
}
10695
}
10796
```
10897

109-
### Key Points
110-
111-
- The `#[Test]` attribute marks test methods, and test classes don't need to inherit from a base class. See [Writing Tests](./writing-tests) for more options.
112-
- Use the `Assert` facade for assertions and `Expect` for expectations.
113-
- Testo provides multiple attributes to extend testing capabilities (retry policies, exception handling, and more).
98+
::: question Why `#[Test]` on a class?
99+
You can put `#[Test]` on a class — then all public methods with return type `void` or `never` become tests.
100+
:::
114101

115102
## Running Tests
116103

@@ -124,7 +111,9 @@ You should see output showing the test results with detailed information about p
124111

125112
## IDE Support
126113

127-
Testo comes with an official [IDEA plugin](https://plugins.jetbrains.com/plugin/28842-testo) for PhpStorm and IntelliJ IDEA.
114+
Testo comes with an official IDEA plugin for PhpStorm and IntelliJ IDEA.
115+
116+
<JetBrainsPlugin />
128117

129118
The plugin provides:
130119
- Running tests directly from the IDE

docs/plugins/assert.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Assert
2+
3+
::: info
4+
This functionality is provided by the `\Testo\Assert\AssertPlugin` plugin, included in the `SuitePlugins` default set.
5+
:::

docs/plugins/retry.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
llms: false
3+
---
4+
5+
# Retry
6+
7+
::: info
8+
This functionality is provided by the `\Testo\Retry\RetryPlugin` plugin, included in the `SuitePlugins` default set.
9+
:::
10+
11+
::: tip Coming Soon
12+
:::

0 commit comments

Comments
 (0)