-
-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the first failing test to demonstrate the issue
- Loading branch information
Showing
3 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...nity-model/src/test/java/net/thucydides/model/requirements/AggregateRequirementsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package net.thucydides.model.requirements; | ||
|
||
import net.thucydides.model.domain.RequirementCache; | ||
import net.thucydides.model.requirements.model.Requirement; | ||
import org.junit.jupiter.api.*; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||
|
||
class AggregateRequirementsTest { | ||
|
||
@BeforeEach | ||
void setUp() { | ||
RequirementCache.getInstance().clear(); | ||
} | ||
|
||
@AfterAll | ||
static void afterAll() { | ||
RequirementCache.getInstance().clear(); | ||
} | ||
|
||
@Nested | ||
@DisplayName("when interpreting Serenity/JS test outcomes") | ||
class SerenityJSTestOutcomes { | ||
|
||
@Test | ||
void should_treat_files_in_a_flat_directory_structure_as_representing_features() { | ||
|
||
List<Requirement> requirements = requirementsFrom(pathTo("serenity-js/spec-0-levels")); | ||
|
||
System.out.println(requirements); | ||
|
||
assertThat(requirements).hasSize(1); | ||
|
||
Requirement feature = requirements.get(0); | ||
|
||
assertThat(feature.getChildren()).hasSize(0); | ||
|
||
assertThat(feature.getName()).isEqualTo("card_payment"); | ||
assertThat(feature.getDisplayName()).isEqualTo("Card payment"); | ||
assertThat(feature.getType()).isEqualTo("feature"); | ||
} | ||
} | ||
|
||
private List<Requirement> requirementsFrom(Path exampleRootDirectory) { | ||
|
||
Path requirementsDirectory = exampleRootDirectory.resolve("spec"); | ||
Path jsonOutcomesDirectory = exampleRootDirectory.resolve("outcomes"); | ||
|
||
Requirements requirements = new AggregateRequirements(jsonOutcomesDirectory, requirementsDirectory.toString()); | ||
|
||
return requirements.getRequirementsService().getRequirements(); | ||
} | ||
|
||
private static Path pathTo(String resource) { | ||
return new File(ClassLoader.getSystemClassLoader().getResource(resource).getFile()).toPath(); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...ty-model/src/test/resources/serenity-js/spec-0-levels/outcomes/scenario-card-payment.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"id": "checkout-should-allow-the-customer-to-pick-their-preferred-card;macos-23-1-0;chromium-120-0-6099-28", | ||
"name": "Checkout should allow the customer to pick their preferred card", | ||
"title": "Checkout should allow the customer to pick their preferred card", | ||
"manual": false, | ||
"testSteps": [ | ||
{ | ||
"number": 1, | ||
"description": "Tess starts with an empty basket", | ||
"startTime": 1701531998839, | ||
"children": [], | ||
"reportData": [], | ||
"screenshots": [], | ||
"duration": 1897, | ||
"result": "SUCCESS" | ||
} | ||
], | ||
"userStory": { | ||
"id": "card-payment", | ||
"storyName": "Card payment", | ||
"displayName": "Card payment", | ||
"path": "card_payment", | ||
"type": "feature", | ||
"narrative": "", | ||
"pathElements": [ | ||
{ | ||
"name": "card_payment", | ||
"description": "" | ||
} | ||
] | ||
}, | ||
"startTime": "2023-12-02T15:46:38.235Z", | ||
"tags": [ | ||
{ | ||
"name": "Card payment", | ||
"type": "feature", | ||
"displayName": "Card payment" | ||
}, | ||
{ | ||
"name": "macOS 23.1.0", | ||
"type": "platform", | ||
"platformName": "macOS", | ||
"platformVersion": "23.1.0", | ||
"displayName": "macOS 23.1.0" | ||
}, | ||
{ | ||
"name": "chromium 120.0.6099.28", | ||
"type": "browser", | ||
"browserName": "chromium", | ||
"browserVersion": "120.0.6099.28", | ||
"displayName": "chromium 120.0.6099.28" | ||
} | ||
], | ||
"featureTag": { | ||
"name": "Card payment", | ||
"type": "feature", | ||
"displayName": "Card payment" | ||
}, | ||
"testSource": "Serenity/JS", | ||
"context": "mac,chrome", | ||
"driver": "chromium", | ||
"result": "SUCCESS", | ||
"duration": 3499 | ||
} |
10 changes: 10 additions & 0 deletions
10
serenity-model/src/test/resources/serenity-js/spec-0-levels/spec/card_payment.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { describe, it } from '@serenity-js/playwright-test' | ||
|
||
describe('Card payment', () => { | ||
|
||
describe('Checkout', () => { | ||
it('should allow the customer to pick their preferred card', async ({ actor }) => { | ||
// ... | ||
}) | ||
}) | ||
}) |