Skip to content

Commit

Permalink
Separated Junit extension from actual scenario builder
Browse files Browse the repository at this point in the history
  • Loading branch information
christianblos committed Nov 16, 2021
1 parent 372b3e4 commit bbfcbda
Show file tree
Hide file tree
Showing 49 changed files with 321 additions and 144 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ public void testLogin() {
```

See more examples in the
[test folder.](./src/test/java/com/innogames/scenariobuilder/examples)
[test folder.](./projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples)
139 changes: 75 additions & 64 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import java.util.regex.Pattern
import org.gradle.util.internal.VersionNumber

plugins {
id 'java-library'
id 'me.qoomon.git-versioning' version '5.1.1'
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'me.qoomon.git-versioning' version "$gitVersioningPluginVersion"
id 'io.github.gradle-nexus.publish-plugin' version "$gradleNexusPublishPluginVersion"
}

group 'com.innogames'
version '0.0.0-SNAPSHOT'
def javaVersion = 11
def gitRepository = 'innogames/junit5-scenario-builder'

def setVersionFromGit() {
// Set project version based on git branch or tag using the git-versioning plugin.
Expand Down Expand Up @@ -46,65 +45,89 @@ def setVersionFromGit() {

setVersionFromGit()

repositories {
mavenCentral()
allprojects {
repositories {
mavenCentral()
}
}

dependencies {
def junitVersion = '5.8.1'
def javaProjects = subprojects.findAll {
return it.name != 'projects'
}

compileOnly "org.junit.jupiter:junit-jupiter-api:$junitVersion"
configure(javaProjects) { project ->
group = rootProject.group
version = rootProject.version

testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'

test {
useJUnitPlatform()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
}
withJavadocJar()
withSourcesJar()
}

java {
withJavadocJar()
withSourcesJar()
}
test {
useJUnitPlatform()
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java

pom {
name = project.name
description = 'Junit5 extension that introduces a Scenario Builder to your tests'
url = 'https://github.com/innogames/junit5-scenario-builder'
licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
publishing {
publications {
mavenJava(MavenPublication) {
from components.java

afterEvaluate {
pom {
name = project.name
description = project.description
url = "https://github.com/${gitRepository}"
licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
name = 'Christian Blos'
email = 'christian.blos@innogames.com'
organization = 'InnoGames GmbH'
organizationUrl = 'https://www.innogames.com/'
}
}
scm {
connection = "scm:git:git://github.com/${gitRepository}.git"
developerConnection = "scm:git:ssh://github.com:${gitRepository}.git"
url = "https://github.com/${gitRepository}"
}
}
}
developers {
developer {
name = 'Christian Blos'
email = 'christian.blos@innogames.com'
organization = 'InnoGames GmbH'
organizationUrl = 'https://www.innogames.com/'
}
}
scm {
connection = 'scm:git:git://github.com/innogames/junit5-scenario-builder.git'
developerConnection = 'scm:git:ssh://github.com:innogames/junit5-scenario-builder.git'
url = 'https://github.com/innogames/junit5-scenario-builder'
}
}
}
}

repositories {
maven {
def releasesRepoUrl = layout.buildDirectory.dir('repos/releases')
def snapshotsRepoUrl = layout.buildDirectory.dir('repos/snapshots')
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
repositories {
maven {
def releasesRepoUrl = layout.buildDirectory.dir('repos/releases')
def snapshotsRepoUrl = layout.buildDirectory.dir('repos/snapshots')
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}

def signingKeyId = findProperty('signing.keyId')
if (signingKeyId) {
signing {
// Use ascii-armored key when SIGNING_KEY environment variable is set.
// If not, signing.secretKeyRingFile property should be present.
def signingKey = System.getenv('SIGNING_KEY')
if (signingKey) {
useInMemoryPgpKeys(signingKeyId, signingKey, findProperty('signing.password'))
}
sign publishing.publications.mavenJava
}
}
}
}
Expand All @@ -120,18 +143,6 @@ nexusPublishing {
}
}

if (hasProperty('signing.keyId')) {
signing {
// Use ascii-armored key when SIGNING_KEY environment variable is set.
// If not, signing.secretKeyRingFile property should be present.
def signingKey = System.getenv('SIGNING_KEY')
if (signingKey) {
useInMemoryPgpKeys(findProperty('signing.keyId'), signingKey, findProperty('signing.password'))
}
sign publishing.publications.mavenJava
}
}

/**
* Updates the version mentioned in the docs. It will use the determined version based on the
* current git branch or tag. You can use a specific version via -Dgit.tag=version system prop.
Expand Down
16 changes: 8 additions & 8 deletions docs/entity-references.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ Here we have 3 builder parts that have to be executed in the correct order:
Please have a look at the [full implementation of this example here][TodoExample].


[RefClass]: ../src/main/java/com/innogames/scenariobuilder/Ref.java
[RefClass]: ../projects/scenario-builder/src/main/java/com/innogames/scenariobuilder/Ref.java

[EntityRefHolder]: ../src/main/java/com/innogames/scenariobuilder/EntityRefHolder.java
[EntityRefHolder]: ../projects/scenario-builder/src/main/java/com/innogames/scenariobuilder/EntityRefHolder.java

[GivenUser]: ../src/test/java/com/innogames/scenariobuilder/examples/gettingstarted/scenario/GivenUser.java
[GivenUser]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/gettingstarted/scenario/GivenUser.java

[UserBuilderPart]: ../src/test/java/com/innogames/scenariobuilder/examples/gettingstarted/scenario/UserBuilderPart.java
[UserBuilderPart]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/gettingstarted/scenario/UserBuilderPart.java

[TodoExample]: ../src/test/java/com/innogames/scenariobuilder/examples/todo
[TodoExample]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/todo

[UserBuilderPart]: ../src/test/java/com/innogames/scenariobuilder/examples/todo/scenario/builder/UserBuilderPart.java
[UserBuilderPart]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/todo/scenario/builder/UserBuilderPart.java

[TodoListBuilderPart]: ../src/test/java/com/innogames/scenariobuilder/examples/todo/scenario/builder/TodoListBuilderPart.java
[TodoListBuilderPart]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/todo/scenario/builder/TodoListBuilderPart.java

[TaskBuilderPart]: ../src/test/java/com/innogames/scenariobuilder/examples/todo/scenario/builder/TaskBuilderPart.java
[TaskBuilderPart]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/todo/scenario/builder/TaskBuilderPart.java
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,4 @@ To accomplish this:
- The `UserBuilderPart` must store the entity in the `GivenUser` object after creation.

Read more about it in the [Entity References](./entity-references.md) section or look at the
[example implementation in the test folder.](../src/test/java/com/innogames/scenariobuilder/examples/gettingstarted)
[example implementation in the test folder.](../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/gettingstarted)
8 changes: 4 additions & 4 deletions docs/ordering.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public class UserBuilderPart implements ScenarioBuilderPart<GivenTodoScenario> {
}
```

[TodoExample]: ../src/test/java/com/innogames/scenariobuilder/examples/todo
[TodoExample]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/todo

[UserBuilderPart]: ../src/test/java/com/innogames/scenariobuilder/examples/todo/scenario/builder/UserBuilderPart.java
[UserBuilderPart]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/todo/scenario/builder/UserBuilderPart.java

[TodoListBuilderPart]: ../src/test/java/com/innogames/scenariobuilder/examples/todo/scenario/builder/TodoListBuilderPart.java
[TodoListBuilderPart]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/todo/scenario/builder/TodoListBuilderPart.java

[TaskBuilderPart]: ../src/test/java/com/innogames/scenariobuilder/examples/todo/scenario/builder/TaskBuilderPart.java
[TaskBuilderPart]: ../projects/junit5-scenario-builder/src/test/java/com/innogames/scenariobuilder/junit5/examples/todo/scenario/builder/TaskBuilderPart.java
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Gradle plugin versions
gitVersioningPluginVersion = 5.1.1
gradleNexusPublishPluginVersion = 1.1.0

# Dependency versions
junitVersion = 5.8.1
10 changes: 10 additions & 0 deletions projects/junit5-scenario-builder/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project.description = 'Junit5 extension that introduces a Scenario Builder to your tests'

dependencies {
api project(':projects:scenario-builder')

compileOnly "org.junit.jupiter:junit-jupiter-api:$junitVersion"

testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.innogames.scenariobuilder.examples.custombuilder;
package com.innogames.scenariobuilder.junit5.examples.custombuilder;

import com.innogames.scenariobuilder.GivenScenarioFactory;
import com.innogames.scenariobuilder.ScenarioBuilder;
import com.innogames.scenariobuilder.ScenarioBuilderPart;
import com.innogames.scenariobuilder.examples.gettingstarted.scenario.GivenAppScenario;
import com.innogames.scenariobuilder.junit5.examples.gettingstarted.scenario.GivenAppScenario;

import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package com.innogames.scenariobuilder.examples.custombuilder;
package com.innogames.scenariobuilder.junit5.examples.custombuilder;

import com.innogames.scenariobuilder.ScenarioBuilder;
import com.innogames.scenariobuilder.ScenarioBuilderPart;
import com.innogames.scenariobuilder.examples.gettingstarted.scenario.GivenAppScenario;
import com.innogames.scenariobuilder.examples.gettingstarted.scenario.UserBuilderPart;
import com.innogames.scenariobuilder.junit5.ScenarioExtension;
import com.innogames.scenariobuilder.junit5.examples.gettingstarted.scenario.GivenAppScenario;
import com.innogames.scenariobuilder.junit5.examples.gettingstarted.scenario.UserBuilderPart;

import org.junit.jupiter.api.extension.ExtensionContext;

import java.util.Collection;
import java.util.List;

/**
* ScenarioExtension that uses a custom {@link ScenarioBuilder} class to reduce
* verbosity in tests.
* ScenarioExtension that uses a custom {@link ScenarioBuilder} class to reduce verbosity in tests.
*/
public class AppScenarioExtensionWithCustomBuilder extends ScenarioExtension<GivenAppScenario> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.innogames.scenariobuilder.examples.custombuilder;
package com.innogames.scenariobuilder.junit5.examples.custombuilder;

import com.innogames.scenariobuilder.Ref;
import com.innogames.scenariobuilder.examples.gettingstarted.domain.UserEntity;
import com.innogames.scenariobuilder.junit5.examples.gettingstarted.domain.UserEntity;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.innogames.scenariobuilder.examples.gettingstarted;
package com.innogames.scenariobuilder.junit5.examples.gettingstarted;

import com.innogames.scenariobuilder.ScenarioBuilder;
import com.innogames.scenariobuilder.examples.gettingstarted.scenario.AppScenarioExtension;
import com.innogames.scenariobuilder.examples.gettingstarted.scenario.GivenAppScenario;
import com.innogames.scenariobuilder.junit5.ScenarioAware;
import com.innogames.scenariobuilder.junit5.examples.gettingstarted.scenario.AppScenarioExtension;
import com.innogames.scenariobuilder.junit5.examples.gettingstarted.scenario.GivenAppScenario;

import org.junit.jupiter.api.extension.ExtendWith;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.innogames.scenariobuilder.examples.gettingstarted;
package com.innogames.scenariobuilder.junit5.examples.gettingstarted;

import com.innogames.scenariobuilder.ScenarioBuilder;
import com.innogames.scenariobuilder.examples.gettingstarted.scenario.AppScenarioExtension;
import com.innogames.scenariobuilder.examples.gettingstarted.scenario.GivenAppScenario;
import com.innogames.scenariobuilder.junit5.examples.gettingstarted.scenario.AppScenarioExtension;
import com.innogames.scenariobuilder.junit5.examples.gettingstarted.scenario.GivenAppScenario;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.innogames.scenariobuilder.examples.gettingstarted;
package com.innogames.scenariobuilder.junit5.examples.gettingstarted;

import com.innogames.scenariobuilder.Ref;
import com.innogames.scenariobuilder.examples.gettingstarted.domain.UserEntity;
import com.innogames.scenariobuilder.junit5.examples.gettingstarted.domain.UserEntity;

import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.innogames.scenariobuilder.junit5.examples.gettingstarted.domain;

import java.util.UUID;

/**
* The User entity that is usually stored in the database.
*/
public class UserEntity {

private UUID id;
private String username;
private String password;

public UUID getId() {
return id;
}

public void setId(UUID id) {
this.id = id;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.innogames.scenariobuilder.examples.gettingstarted.scenario;
package com.innogames.scenariobuilder.junit5.examples.gettingstarted.scenario;

import com.innogames.scenariobuilder.ScenarioBuilderPart;
import com.innogames.scenariobuilder.junit5.ScenarioExtension;
Expand Down
Loading

0 comments on commit bbfcbda

Please sign in to comment.