forked from corda/corda
-
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.
Add module for end-to-end testing library
- Loading branch information
Tommy Lillehagen
committed
Feb 2, 2018
1 parent
258b562
commit f3d2a76
Showing
13 changed files
with
234 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,107 @@ | ||
buildscript { | ||
ext.kotlin_version = '1.2.21' | ||
ext.commonsio_version = '2.6' | ||
ext.cucumber_version = '1.2.5' | ||
ext.crash_version = 'cce5a00f114343c1145c1d7756e1dd6df3ea984e' | ||
ext.docker_client_version = '8.11.0' | ||
|
||
repositories { | ||
maven { | ||
jcenter() | ||
url 'https://jitpack.io' | ||
} | ||
} | ||
|
||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
group 'net.corda.behave' | ||
|
||
apply plugin: 'java' | ||
apply plugin: 'kotlin' | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
sourceSets { | ||
scenario { | ||
java { | ||
compileClasspath += main.output | ||
runtimeClasspath += main.output | ||
srcDir file('src/scenario/kotlin') | ||
} | ||
resources.srcDir file('src/scenario/resources') | ||
} | ||
} | ||
|
||
configurations { | ||
scenarioCompile.extendsFrom testCompile | ||
scenarioRuntime.extendsFrom testRuntime | ||
} | ||
|
||
dependencies { | ||
|
||
// Library | ||
|
||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" | ||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" | ||
|
||
compile("com.github.corda.crash:crash.shell:$crash_version") { | ||
exclude group: "org.slf4j", module: "slf4j-jdk14" | ||
exclude group: "org.bouncycastle" | ||
} | ||
|
||
compile("com.github.corda.crash:crash.connectors.ssh:$crash_version") { | ||
exclude group: "org.slf4j", module: "slf4j-jdk14" | ||
exclude group: "org.bouncycastle" | ||
} | ||
|
||
compile "com.spotify:docker-client:$docker_client_version" | ||
|
||
// Unit Tests | ||
|
||
testCompile "junit:junit:$junit_version" | ||
|
||
// Scenarios / End-to-End Tests | ||
|
||
scenarioCompile "info.cukes:cucumber-java8:$cucumber_version" | ||
scenarioCompile "info.cukes:cucumber-junit:$cucumber_version" | ||
scenarioCompile "info.cukes:cucumber-picocontainer:$cucumber_version" | ||
scenarioCompile "org.assertj:assertj-core:$assertj_version" | ||
scenarioCompile "org.slf4j:log4j-over-slf4j:$slf4j_version" | ||
scenarioCompile "org.slf4j:jul-to-slf4j:$slf4j_version" | ||
scenarioCompile "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" | ||
scenarioCompile "org.apache.logging.log4j:log4j-core:$log4j_version" | ||
scenarioCompile "commons-io:commons-io:$commonsio_version" | ||
|
||
} | ||
|
||
compileKotlin { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
compileTestKotlin { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
compileScenarioKotlin { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
test { | ||
testLogging.showStandardStreams = true | ||
} | ||
|
||
task scenarios(type: Test) { | ||
setTestClassesDirs sourceSets.scenario.output.getClassesDirs() | ||
classpath = sourceSets.scenario.runtimeClasspath | ||
outputs.upToDateWhen { false } | ||
} | ||
|
||
scenarios.mustRunAfter test | ||
scenarios.dependsOn test |
7 changes: 7 additions & 0 deletions
7
experimental/behave/src/main/kotlin/net/corda/behave/Utility.kt
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,7 @@ | ||
package net.corda.behave | ||
|
||
object Utility { | ||
|
||
fun dummy() = true | ||
|
||
} |
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 @@ | ||
import cucumber.api.CucumberOptions | ||
import cucumber.api.junit.Cucumber | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(Cucumber::class) | ||
@CucumberOptions( | ||
features = arrayOf("src/scenario/resources/features"), | ||
glue = arrayOf("net.corda.behave.scenarios"), | ||
plugin = arrayOf("pretty") | ||
) | ||
@Suppress("KDocMissingDocumentation") | ||
class CucumberTest |
17 changes: 17 additions & 0 deletions
17
experimental/behave/src/scenario/kotlin/net/corda/behave/scenarios/ScenarioHooks.kt
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,17 @@ | ||
package net.corda.behave.scenarios | ||
|
||
import cucumber.api.java.After | ||
import cucumber.api.java.Before | ||
|
||
@Suppress("KDocMissingDocumentation") | ||
class ScenarioHooks(private val state: ScenarioState) { | ||
|
||
@Before | ||
fun beforeScenario() { | ||
} | ||
|
||
@After | ||
fun afterScenario() { | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
experimental/behave/src/scenario/kotlin/net/corda/behave/scenarios/ScenarioState.kt
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,7 @@ | ||
package net.corda.behave.scenarios | ||
|
||
class ScenarioState { | ||
|
||
var count: Int = 0 | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
experimental/behave/src/scenario/kotlin/net/corda/behave/scenarios/StepsBlock.kt
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,3 @@ | ||
package net.corda.behave.scenarios | ||
|
||
typealias StepsBlock = (StepsContainer.() -> Unit) -> Unit |
25 changes: 25 additions & 0 deletions
25
experimental/behave/src/scenario/kotlin/net/corda/behave/scenarios/StepsContainer.kt
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,25 @@ | ||
package net.corda.behave.scenarios | ||
|
||
import cucumber.api.java8.En | ||
import net.corda.behave.scenarios.steps.dummySteps | ||
import org.slf4j.Logger | ||
import org.slf4j.LoggerFactory | ||
|
||
@Suppress("KDocMissingDocumentation") | ||
class StepsContainer(val state: ScenarioState) : En { | ||
|
||
val log: Logger = LoggerFactory.getLogger(StepsContainer::class.java) | ||
|
||
private val stepDefinitions: List<(StepsBlock) -> Unit> = listOf( | ||
::dummySteps | ||
) | ||
|
||
init { | ||
stepDefinitions.forEach { it({ this.steps(it) }) } | ||
} | ||
|
||
private fun steps(action: (StepsContainer.() -> Unit)) { | ||
action(this) | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
experimental/behave/src/scenario/kotlin/net/corda/behave/scenarios/steps/DummySteps.kt
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,18 @@ | ||
package net.corda.behave.scenarios.steps | ||
|
||
import net.corda.behave.scenarios.StepsBlock | ||
import org.assertj.core.api.Assertions.assertThat | ||
|
||
fun dummySteps(steps: StepsBlock) = steps { | ||
|
||
When<Int, String>("^(\\d+) dumm(y|ies) exists?$") { count, _ -> | ||
state.count = count | ||
log.info("Checking pre-condition $count") | ||
} | ||
|
||
Then("^there is a dummy$") { | ||
assertThat(state.count).isGreaterThan(0) | ||
log.info("Checking outcome ${state.count}") | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
experimental/behave/src/scenario/resources/features/dummy.feature
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: Dummy | ||
Lorem ipsum | ||
|
||
Scenario: Noop | ||
Given 15 dummies exist | ||
Then there is a dummy |
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Configuration status="info"> | ||
<ThresholdFilter level="info"/> | ||
<Appenders> | ||
<Console name="STDOUT" target="SYSTEM_OUT" ignoreExceptions="false"> | ||
<PatternLayout pattern="%m%n"/> | ||
</Console> | ||
</Appenders> | ||
<Loggers> | ||
<Root level="info"> | ||
<AppenderRef ref="STDOUT"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
13 changes: 13 additions & 0 deletions
13
experimental/behave/src/test/kotlin/net/corda/behave/UtilityTests.kt
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,13 @@ | ||
package net.corda.behave | ||
|
||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
class UtilityTests { | ||
|
||
@Test | ||
fun `dummy`() { | ||
Assert.assertEquals(true, Utility.dummy()) | ||
} | ||
|
||
} |
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