-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JMockit coverage and PITest reports added.
- Loading branch information
Daniele Demichelis
committed
May 1, 2017
1 parent
86a7282
commit 891a98b
Showing
6 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>tdd-parent</artifactId> | ||
<groupId>com.danidemi.tutorial.tdd</groupId> | ||
<version>0.0.2-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>bdd-helloworld</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jbehave</groupId> | ||
<artifactId>jbehave-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
</project> |
34 changes: 34 additions & 0 deletions
34
bdd-helloworld/src/test/java/com/danidemi/tdd/bdd/IncreaseStepsFactory.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,34 @@ | ||
package com.danidemi.tdd.bdd; | ||
|
||
import org.jbehave.core.annotations.Given; | ||
import org.jbehave.core.annotations.Then; | ||
import org.jbehave.core.annotations.When; | ||
|
||
import java.util.Random; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public class IncreaseStepsFactory { | ||
private int counter; | ||
private int previousValue; | ||
|
||
@Given("a counter") | ||
public void aCounter() { | ||
} | ||
|
||
@Given("the counter has any integral value") | ||
public void counterHasAnyIntegralValue() { | ||
counter = new Random().nextInt(); | ||
previousValue = counter; | ||
} | ||
|
||
@When("the user increases the counter") | ||
public void increasesTheCounter() { | ||
counter++; | ||
} | ||
|
||
@Then("the value of the counter must be 1 greater than previous value") | ||
public void theValueOfTheCounterMustBe1Greater() { | ||
assertTrue(1 == counter - previousValue); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
bdd-helloworld/src/test/java/com/danidemi/tdd/bdd/IncreaseStoryLiveTest.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,42 @@ | ||
package com.danidemi.tdd.bdd; | ||
|
||
import org.jbehave.core.configuration.Configuration; | ||
import org.jbehave.core.configuration.MostUsefulConfiguration; | ||
import org.jbehave.core.failures.FailingUponPendingStep; | ||
import org.jbehave.core.io.LoadFromClasspath; | ||
import org.jbehave.core.junit.JUnitStories; | ||
import org.jbehave.core.reporters.StoryReporterBuilder; | ||
import org.jbehave.core.steps.InjectableStepsFactory; | ||
import org.jbehave.core.steps.InstanceStepsFactory; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.jbehave.core.io.CodeLocations.codeLocationFromClass; | ||
|
||
public class IncreaseStoryLiveTest extends JUnitStories { | ||
|
||
@Override | ||
public Configuration configuration() { | ||
return new MostUsefulConfiguration() | ||
.useStoryLoader(new LoadFromClasspath(this.getClass())) | ||
.useFailureStrategy(new FailingUponPendingStep()) | ||
.useStoryReporterBuilder(new StoryReporterBuilder() | ||
.withCodeLocation(codeLocationFromClass(this.getClass())) | ||
.withDefaultFormats()); | ||
} | ||
|
||
@Override | ||
public InjectableStepsFactory stepsFactory() { | ||
return new InstanceStepsFactory(configuration(), new IncreaseStepsFactory()); | ||
} | ||
|
||
/** | ||
* .story file path to be parsed by JBehave | ||
*/ | ||
@Override | ||
protected List<String> storyPaths() { | ||
return Arrays.asList("increase.story"); | ||
} | ||
|
||
} |
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,6 @@ | ||
Scenario: when a user increases a counter, its value is increased by 1 | ||
|
||
Given a counter | ||
And the counter has any integral value | ||
When the user increases the counter | ||
Then the value of the counter must be 2 greater than previous value |
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
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