Skip to content

Commit

Permalink
Add inline and shared datasets for Pest
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-rafalko committed May 13, 2021
1 parent acf45a9 commit 9f29d95
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/e2e/PestTestFramework/expected-output.txt
@@ -1,8 +1,8 @@
Total: 5
Total: 11

Killed: 4
Killed: 9
Errored: 0
Escaped: 1
Escaped: 2
Timed Out: 0
Skipped: 0
Not Covered: 0
15 changes: 15 additions & 0 deletions tests/e2e/PestTestFramework/src/ForPestWithDataProvider.php
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);


namespace PestTestFramework;


final class ForPestWithDataProvider
{
public function div(float $a, float $b): float
{
return $a / $b;
}
}
6 changes: 6 additions & 0 deletions tests/e2e/PestTestFramework/tests/Datasets/Floats.php
@@ -0,0 +1,6 @@
<?php

dataset('floats', [
[1.0, 2.0, 0.5],
[3.0, 3.0, 1.0],
]);
17 changes: 17 additions & 0 deletions tests/e2e/PestTestFramework/tests/ForPestWithDataProviderTest.php
@@ -0,0 +1,17 @@
<?php

use PestTestFramework\ForPestWithDataProvider;

test('tests division with inline dataset', function (float $a, float $b, float $expectedResult) {
$sourceClass = new ForPestWithDataProvider();

expect($sourceClass->div($a, $b))->toBe($expectedResult);
})->with([
[2.0, 4.0, 0.5]
]);

test('tests division with shared dataset', function (float $a, float $b, float $expectedResult) {
$sourceClass = new ForPestWithDataProvider();

expect($sourceClass->div($a, $b))->toBe($expectedResult);
})->with('floats');

0 comments on commit 9f29d95

Please sign in to comment.