Skip to content

Commit

Permalink
Added the first failing test to demonstrate the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-molak committed Dec 27, 2023
1 parent f4fd076 commit ee7838a
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
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();
}
}
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
}
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 }) => {
// ...
})
})
})

0 comments on commit ee7838a

Please sign in to comment.