Tutorial


Here we are! 🚀

Your project is configured and ready for its first tests.

#Namespaces

We'll add two namespaces to our composer.json file:

  • Shop: custom test scenarios and elements
  • Tests: test suites
Copied!
1"autoload": {
2 "psr-4": {
3 "Shop\\": "src/"
4 }
5},
6"autoload-dev": {
7 "psr-4": {
8 "Tests\\": "Tests/"
9 }
10},

#Create a suite

Inside the Tests folder, create a file nammed as you want. For exemple : First.php

Copied!
1namespace Tests;
2 
3use PrestaFlow\Library\Tests\TestsSuite;
4 
5class First extends TestsSuite
6{
7 public function init()
8 {
9 $this
10 ->describe('PrestaFlow: my first scenario')
11 ;
12 }
13}

If you run the prestaflow:default script, you will see your first suite in action !

You can run it right now, locally, without any account or cloud setup:

Copied!
1composer prestaflow:default

The CLI reads your .env (see Configuration) and executes the suites found in your Tests/ folder. No PrestaFlow.io account, token or network call is required — results stay on your machine.

#Add steps

Copied!
1namespace Tests;
2 
3use PrestaFlow\Library\Tests\TestsSuite;
4 
5class First extends TestsSuite
6{
7 public function init()
8 {
9 $this
10 ->describe('PrestaFlow: my first scenario')
11 ->todo('To be done', function () {
12 })
13 ->skip('will be skipped', function () {
14 })
15 ;
16 }
17}

#Create a scenario

In the src/Tests/Scenarios folder, add a file named DoNothing.php.

In it, add your first scenario as follows:

Copied!
1namespace Shop\Tests\Scenarios;
2 
3use PrestaFlow\Library\Scenarios\Scenario;
4 
5class DoNothing extends Scenario
6{
7 public function steps($testSuite)
8 {
9 $testSuite
10 ->todo('will do nothing (again)', function () {
11 })
12 ;
13 
14 return $testSuite;
15 }
16}

You can now use it into your suite.

Copied!
1namespace Tests;
2 
3use PrestaFlow\Library\Tests\TestsSuite;
4use Shop\Tests\Scenarios\DoNothing;
5 
6class First extends TestsSuite
7{
8 public function init()
9 {
10 $this
11 ->describe('PrestaFlow: my first scenario')
12 ->scenario(DoNothing::class)
13 ;
14 }
15}

#Run your suite

Everything you need to run PrestaFlow lives in your project — the CLI works fully offline, no PrestaFlow.io account required.

Copied!
1composer prestaflow:default

Want to target a specific folder or format the output? A few useful variants:

Copied!
1composer prestaflow:default ./Tests
2composer prestaflow:default -- --output="compact"
3composer prestaflow:json

See Installation → Run for the full list of flags (drafts, groups, JSON file output, …).

Pushing results to the PrestaFlow.io dashboard is entirely optional and covered in the CI integrations section. The local CLI never needs it.