Skip to content
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

Fix updates in Cucumber tests with fixtures (fixes #483) #531

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ private void startFixture(final String uuid, final FixtureResult result) {
storage.put(uuid, result);
result.setStage(Stage.RUNNING);
result.setStart(System.currentTimeMillis());
threadContext.clear();
threadContext.start(uuid);
}

Expand Down Expand Up @@ -276,7 +275,6 @@ public void stopFixture(final String uuid) {
fixture.setStop(System.currentTimeMillis());

storage.remove(uuid);
threadContext.clear();

notifier.afterFixtureStop(fixture);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,67 @@ void shouldUpdateTest() {
.containsExactly(stepName);
}

@Test
void shouldUpdateTestWithFixture() {
final String containerUuid = randomId();
final String containerName = randomName();

TestResultContainer container = new TestResultContainer()
.setUuid(containerUuid)
.setName(containerName);
lifecycle.startTestContainer(container);

final String uuid = randomId();
final String name = randomName();

final TestResult result = new TestResult().setUuid(uuid).setName(name);
lifecycle.scheduleTestCase(result);
lifecycle.startTestCase(uuid);

final String firstUuid = randomId();
final String firstName = randomName();
final FixtureResult first = new FixtureResult().setName(firstName);

lifecycle.startPrepareFixture(containerUuid, firstUuid, first);
lifecycle.stopFixture(firstUuid);

final String stepUuid = randomId();
final String stepName = randomName();

final StepResult step = new StepResult().setName(stepName);
lifecycle.startStep(uuid, stepUuid, step);

final String description = randomName();
final String fullName = randomName();

lifecycle.updateTestCase(uuid, testResult -> testResult.setDescription(description));
lifecycle.updateTestCase(testResult -> testResult.setFullName(fullName));

lifecycle.stopStep(stepUuid);

lifecycle.stopTestCase(uuid);

lifecycle.stopTestContainer(containerUuid);

lifecycle.writeTestCase(uuid);
lifecycle.writeTestContainer(containerUuid);

final ArgumentCaptor<TestResult> captor = forClass(TestResult.class);
verify(writer, times(1)).write(captor.capture());

final TestResult actual = captor.getValue();
assertThat(actual)
.isNotNull()
.hasFieldOrPropertyWithValue("uuid", uuid)
.hasFieldOrPropertyWithValue("description", description)
.hasFieldOrPropertyWithValue("name", name)
.hasFieldOrPropertyWithValue("fullName", fullName);

assertThat(actual.getSteps())
.flatExtracting(StepResult::getName)
.containsExactly(stepName);
}

@Test
void shouldUpdateContainer() {
final String uuid = randomId();
Expand Down