-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b785890
commit 57a9b03
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/main/java/com/github/lothar/hsystem/InstructionProcessor.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,12 @@ | ||
package com.github.lothar.hsystem; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class InstructionProcessor { | ||
|
||
public void process(String instruction) { | ||
System.out.println("Hello world !"); | ||
} | ||
|
||
} |
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 @@ | ||
Feature: Execute a simple instruction locally | ||
|
||
@done | ||
Scenario: Prints something in the console when user asks so | ||
When I say "Print \"Hello world !\" in the console" | ||
Then "Hello world !" is printed in the console |
16 changes: 16 additions & 0 deletions
16
src/test/java/com/github/lothar/hsystem/cucumber/CucumberTests.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,16 @@ | ||
package com.github.lothar.hsystem.cucumber; | ||
|
||
import org.junit.runner.RunWith; | ||
|
||
import cucumber.api.CucumberOptions; | ||
import cucumber.api.junit.Cucumber; | ||
|
||
@RunWith(Cucumber.class) | ||
@CucumberOptions(plugin = "pretty", | ||
monochrome = true, | ||
features = "src/test/features", | ||
glue = { "com.github.lothar.hsystem.cucumber", "cucumber.api.spring" }, | ||
tags = { "~@ignore", "@done" }) | ||
public class CucumberTests { | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
src/test/java/com/github/lothar/hsystem/cucumber/SimplePrintStepDefs.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,45 @@ | ||
package com.github.lothar.hsystem.cucumber; | ||
|
||
import static org.mockito.Mockito.verify; | ||
|
||
import java.io.PrintStream; | ||
|
||
import javax.annotation.Resource; | ||
|
||
import org.mockito.Mockito; | ||
import org.springframework.boot.test.SpringApplicationContextLoader; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import com.github.lothar.hsystem.HSystemApplication; | ||
import com.github.lothar.hsystem.InstructionProcessor; | ||
|
||
import cucumber.api.java.Before; | ||
import cucumber.api.java.en.Then; | ||
import cucumber.api.java.en.When; | ||
|
||
@ContextConfiguration(classes = HSystemApplication.class, loader = SpringApplicationContextLoader.class) | ||
public class SimplePrintStepDefs { | ||
|
||
@Resource | ||
private InstructionProcessor processor; | ||
private PrintStream sysoutMock = Mockito.mock(PrintStream.class); | ||
|
||
@Before | ||
public void before() { | ||
System.setOut(sysoutMock); | ||
} | ||
|
||
public void after() { | ||
System.setOut(System.out); | ||
} | ||
|
||
@When("^I say \"Print (.*) in the console\"$") | ||
public void i_say_print_in_the_console(String instruction) { | ||
processor.process("Print " + instruction + " in the console"); | ||
} | ||
|
||
@Then("^\"([^\"]*)\" is printed in the console$") | ||
public void is_printed_in_the_console(String expectedOutput) { | ||
verify(sysoutMock).println(expectedOutput); | ||
} | ||
} |