Skip to content

Reorganizing some headers #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 40 additions & 40 deletions docs/07-AdvancedUsage.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ For Cept you should use simple comments:

This way you can easily control which tests will be executed for each environment.

### Current values
## Get Scenario Metadata

Sometimes you may need to change the test behavior in real time.
For instance, the behavior of the same test may differ in Firefox and in Chrome.
Expand Down Expand Up @@ -550,45 +550,7 @@ public function myTest(\AcceptanceTester $I, \Codeception\Scenario $scenario)

`Codeception\Scenario` is also available in Actor classes and StepObjects. You can access it with `$this->getScenario()`.

### Dependencies

With the `@depends` annotation you can specify a test that should be passed before the current one.
If that test fails, the current test will be skipped. You should pass the method name of the test you are relying on.

{% highlight php %}

<?php
class ModeratorCest {

public function login(AcceptanceTester $I)
{
// logs moderator in
}

/**
* @depends login
*/
public function banUser(AcceptanceTester $I)
{
// bans user
}
}

{% endhighlight %}

`@depends` applies to the `Cest` and `Codeception\Test\Unit` formats. Dependencies can be set across different classes.
To specify a dependent test from another file you should provide a *test signature*.
Normally, the test signature matches the `className:methodName` format.
But to get the exact test signature just run the test with the `--steps` option to see it:

{% highlight yaml %}
Signature: ModeratorCest:login`

{% endhighlight %}

Codeception reorders tests so dependent tests will always be executed before the tests that rely on them.

### Shuffle
## Shuffle

By default Codeception runs tests in alphabetic order.
To ensure that tests are not depending on each other (unless explicitly declared via `@depends`) you can enable `shuffle` option.
Expand Down Expand Up @@ -627,6 +589,44 @@ codecept run --seed 1872290562

{% endhighlight %}

### Dependencies

With the `@depends` annotation you can specify a test that should be passed before the current one.
If that test fails, the current test will be skipped. You should pass the method name of the test you are relying on.

{% highlight php %}

<?php
class ModeratorCest {

public function login(AcceptanceTester $I)
{
// logs moderator in
}

/**
* @depends login
*/
public function banUser(AcceptanceTester $I)
{
// bans user
}
}

{% endhighlight %}

`@depends` applies to the `Cest` and `Codeception\Test\Unit` formats. Dependencies can be set across different classes.
To specify a dependent test from another file you should provide a *test signature*.
Normally, the test signature matches the `className:methodName` format.
But to get the exact test signature just run the test with the `--steps` option to see it:

{% highlight yaml %}
Signature: ModeratorCest:login`

{% endhighlight %}

Codeception reorders tests so dependent tests will always be executed before the tests that rely on them.

## Running from different folders

If you have several projects with Codeception tests, you can use a single `codecept` file to run all of your tests.
Expand Down