-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from YamStranger/test_reorganisation
Tests are reorganised to enable as more parallel tests as it possible
- Loading branch information
Showing
12 changed files
with
973 additions
and
739 deletions.
There are no files selected for viewing
651 changes: 0 additions & 651 deletions
651
src/test/java/net/serenitybdd/jbehave/WhenRunningJBehaveStories.java
This file was deleted.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
src/test/java/net/serenitybdd/jbehave/WhenRunningJBehaveStoriesWithError.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,103 @@ | ||
package net.serenitybdd.jbehave; | ||
|
||
import net.thucydides.core.model.TestOutcome; | ||
import net.thucydides.core.model.TestResult; | ||
import net.thucydides.core.util.EnvironmentVariables; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
import static net.thucydides.core.matchers.PublicThucydidesMatchers.containsResults; | ||
import static net.thucydides.core.model.TestResult.*; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
public class WhenRunningJBehaveStoriesWithError extends AbstractJBehaveStory { | ||
|
||
final static class AStorySample extends SerenityStories { | ||
|
||
public AStorySample(EnvironmentVariables environmentVariables) { | ||
super(environmentVariables); | ||
} | ||
|
||
protected AStorySample(String storyName) { | ||
findStoriesCalled(storyName); | ||
} | ||
} | ||
|
||
@Test | ||
public void stories_with_errors_should_be_reported_as_failing() throws Throwable { | ||
|
||
// Given | ||
SerenityStories failingStory = newStory("aBehaviorThrowingAnException.story"); | ||
|
||
// When | ||
run(failingStory); | ||
|
||
// Then | ||
List<TestOutcome> outcomes = loadTestOutcomes(); | ||
assertThat(outcomes.size(), is(1)); | ||
assertThat(outcomes.get(0).getResult(), is(TestResult.ERROR)); | ||
} | ||
|
||
private void runStories(SerenityStories stories) throws Throwable { | ||
run(stories); | ||
} | ||
|
||
@Test | ||
public void errored_stories_should_be_reported_as_having_an_error() throws Throwable { | ||
|
||
// Given | ||
SerenityStories failingStory = newStory("aBehaviorWithAnError.story"); | ||
|
||
// When | ||
run(failingStory); | ||
|
||
// Then | ||
List<TestOutcome> outcomes = loadTestOutcomes(); | ||
assertThat(outcomes.size(), is(1)); | ||
assertThat(outcomes.get(0).getResult(), is(TestResult.ERROR)); | ||
} | ||
|
||
@Test | ||
public void a_test_running_a_failing_story_should_fail() throws Throwable { | ||
SerenityStories stories = new AFailingBehavior(); | ||
stories.setSystemConfiguration(systemConfiguration); | ||
runStories(stories); | ||
|
||
assert !raisedErrors.isEmpty(); | ||
} | ||
|
||
@Test | ||
public void a_test_running_a_failing_story_among_several_should_fail() throws Throwable { | ||
SerenityStories stories = new ASetOfBehaviorsContainingFailures(); | ||
stories.setSystemConfiguration(systemConfiguration); | ||
runStories(stories); | ||
|
||
assert !raisedErrors.isEmpty(); | ||
} | ||
|
||
@Test | ||
public void failing_stories_run_in_junit_should_fail() throws Throwable { | ||
|
||
// Given | ||
SerenityStories failingStory = newStory("aFailingBehavior.story"); | ||
|
||
// When | ||
runStories(failingStory); | ||
|
||
assert !raisedErrors.isEmpty(); | ||
} | ||
|
||
@Test | ||
public void stories_with_errors_run_in_junit_should_fail() throws Throwable { | ||
|
||
// Given | ||
SerenityStories failingStory = newStory("aBehaviorThrowingAnException.story"); | ||
|
||
// When | ||
runStories(failingStory); | ||
|
||
assert !raisedErrors.isEmpty(); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/test/java/net/serenitybdd/jbehave/WhenRunningJBehaveStoriesWithFailure.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,75 @@ | ||
package net.serenitybdd.jbehave; | ||
|
||
import net.thucydides.core.model.TestOutcome; | ||
import net.thucydides.core.model.TestResult; | ||
import net.thucydides.core.util.EnvironmentVariables; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
import static net.thucydides.core.model.TestResult.FAILURE; | ||
import static net.thucydides.core.model.TestResult.SUCCESS; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
public class WhenRunningJBehaveStoriesWithFailure extends AbstractJBehaveStory { | ||
|
||
final static class AStorySample extends SerenityStories { | ||
|
||
public AStorySample(EnvironmentVariables environmentVariables) { | ||
super(environmentVariables); | ||
} | ||
|
||
protected AStorySample(String storyName) { | ||
findStoriesCalled(storyName); | ||
} | ||
} | ||
|
||
@Test | ||
public void failing_stories_should_be_reported_as_failing() throws Throwable { | ||
|
||
// Given | ||
SerenityStories failingStory = newStory("aFailingBehavior.story"); | ||
|
||
// When | ||
run(failingStory); | ||
|
||
// Then | ||
List<TestOutcome> outcomes = loadTestOutcomes(); | ||
assertThat(outcomes.size(), is(1)); | ||
assertThat(outcomes.get(0).getResult(), is(TestResult.FAILURE)); | ||
} | ||
|
||
@Test | ||
public void should_not_reset_steps_for_each_scenario_if_configured() throws Throwable { | ||
|
||
environmentVariables.setProperty("reset.steps.each.scenario", "false"); | ||
// Given | ||
SerenityStories passingStory = newStory("aPassingBehaviorWithSeveralScenarios.story"); | ||
|
||
// When | ||
run(passingStory); | ||
|
||
// Then | ||
List<TestOutcome> outcomes = loadTestOutcomes(); | ||
assertThat(outcomes.size(), is(2)); | ||
assertThat(outcomes.get(0).getResult(), is(TestResult.SUCCESS)); | ||
assertThat(outcomes.get(1).getResult(), is(TestResult.FAILURE)); | ||
} | ||
|
||
@Test | ||
public void variables_are_reset_between_steps_by_default() throws Throwable { | ||
|
||
// Given | ||
SerenityStories sharedVariablesStory = newStory("aBehaviorWithSharedVariables.story"); | ||
|
||
// When | ||
run(sharedVariablesStory); | ||
|
||
// Then | ||
List<TestOutcome> outcomes = loadTestOutcomes(); | ||
assertThat(outcomes.size(), is(2)); | ||
assertThat(outcomes.get(0).getResult(), is(SUCCESS)); | ||
assertThat(outcomes.get(1).getResult(), is(FAILURE)); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/test/java/net/serenitybdd/jbehave/WhenRunningJBehaveStoriesWithIgnored.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,73 @@ | ||
package net.serenitybdd.jbehave; | ||
|
||
import net.thucydides.core.model.TestOutcome; | ||
import net.thucydides.core.model.TestResult; | ||
import net.thucydides.core.util.EnvironmentVariables; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
import static net.thucydides.core.matchers.PublicThucydidesMatchers.containsResults; | ||
import static net.thucydides.core.model.TestResult.IGNORED; | ||
import static net.thucydides.core.model.TestResult.PENDING; | ||
import static net.thucydides.core.model.TestResult.SUCCESS; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
public class WhenRunningJBehaveStoriesWithIgnored extends AbstractJBehaveStory { | ||
|
||
final static class AStorySample extends SerenityStories { | ||
|
||
public AStorySample(EnvironmentVariables environmentVariables) { | ||
super(environmentVariables); | ||
} | ||
|
||
protected AStorySample(String storyName) { | ||
findStoriesCalled(storyName); | ||
} | ||
} | ||
|
||
private void runStories(SerenityStories stories) throws Throwable { | ||
run(stories); | ||
} | ||
|
||
@Test | ||
public void a_test_running_a_failing_story_should_not_fail_if_ignore_failures_in_stories_is_set_to_true() throws Throwable { | ||
|
||
systemConfiguration.getEnvironmentVariables().setProperty("ignore.failures.in.stories", "true"); | ||
SerenityStories stories = new AFailingBehavior(); | ||
stories.setSystemConfiguration(systemConfiguration); | ||
runStories(stories); | ||
} | ||
|
||
@Test | ||
public void should_mark_scenarios_with_failing_assumption_as_skipped() throws Throwable { | ||
|
||
// Given | ||
SerenityStories stories = new ABehaviorWithAFailingAssumption(environmentVariables); | ||
|
||
// When | ||
run(stories); | ||
|
||
// Then | ||
List<TestOutcome> outcomes = loadTestOutcomes(); | ||
assertThat(outcomes.size(), is(2)); | ||
assertThat(outcomes.get(0).getResult(), is(IGNORED)); | ||
assertThat(outcomes.get(1).getResult(), is(SUCCESS)); | ||
} | ||
|
||
@Test | ||
public void stories_with_failing_assumptions_should_be_ignored() throws Throwable { | ||
|
||
// Given | ||
SerenityStories pendingStory = newStory("aBehaviorWithAFailingAssumption.story"); | ||
|
||
// When | ||
run(pendingStory); | ||
|
||
// Then | ||
List<TestOutcome> outcomes = loadTestOutcomes(); | ||
assertThat(outcomes.get(0).getResult(), is(TestResult.IGNORED)); | ||
assertThat(outcomes.get(1).getResult(), is(TestResult.SUCCESS)); | ||
} | ||
} |
Oops, something went wrong.