You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2020/02/26 07:02:26 UTC

[isis-app-simpleapp] branch master updated: improves BDD (ISIS-2299)

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis-app-simpleapp.git


The following commit(s) were added to refs/heads/master by this push:
     new 373be31  improves BDD (ISIS-2299)
373be31 is described below

commit 373be314650a6e27d718c16ff4154e1c384a7eab
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Feb 26 07:01:22 2020 +0000

    improves BDD (ISIS-2299)
---
 .../integtests/tests/SimpleObject_IntegTest.java   |  2 +-
 webapp/pom.xml                                     | 39 +++++++++++++++++++---
 .../domainapp/webapp/bdd/RunCucumberSpecs.java     |  7 ++++
 .../domainapp/webapp/bdd/RunIntegBddSpecs.java     | 26 ---------------
 .../{ => domain}/SimpleObjectsStepDef.java         |  2 +-
 .../fixtures/DomainAppDemoStepDef.java             |  2 +-
 .../infrastructure/BootstrapStepDef.java           |  2 +-
 .../infrastructure/TransactionalStepDef.java       |  2 +-
 .../SimpleObjectSpec_listAllAndCreate.feature      |  0
 .../src/test/resources/junit-platform.properties   | 13 ++++++++
 10 files changed, 60 insertions(+), 35 deletions(-)

diff --git a/module-simple/src/test/java/domainapp/modules/simple/integtests/tests/SimpleObject_IntegTest.java b/module-simple/src/test/java/domainapp/modules/simple/integtests/tests/SimpleObject_IntegTest.java
index 40544da..9bf1375 100644
--- a/module-simple/src/test/java/domainapp/modules/simple/integtests/tests/SimpleObject_IntegTest.java
+++ b/module-simple/src/test/java/domainapp/modules/simple/integtests/tests/SimpleObject_IntegTest.java
@@ -109,7 +109,7 @@ public class SimpleObject_IntegTest extends SimpleModuleIntegTestAbstract {
             });
 
             // then
-            assertThat(cause.getMessage(), containsString("Exclamation mark is not allowed."));
+            assertThat(cause.getMessage(), containsString("Character '!' is not allowed."));
         }
     }
 
diff --git a/webapp/pom.xml b/webapp/pom.xml
index 15a1833..24ae1f0 100644
--- a/webapp/pom.xml
+++ b/webapp/pom.xml
@@ -17,6 +17,7 @@
 
     <properties>
         <maven-cucumber-reporting.version>4.11.2</maven-cucumber-reporting.version>
+        <skipBDD>${skipTests}</skipBDD>
     </properties>
 
     <build>
@@ -49,14 +50,44 @@
             </testResource>
         </testResources>
         <plugins>
+            <!-- Work around. Surefire does not use JUnit's Test Engine discovery functionality -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>cucumber-cli</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                        <configuration>
+                            <target>
+                                <!--
+                                as per
+                                https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/resources/io/cucumber/core/options/USAGE.txt
+                                -->
+                                <echo message="Running Cucumber CLI" />
+                                <java classname="io.cucumber.core.cli.Main" fork="true" failonerror="true" newenvironment="true" maxmemory="1024m" classpathref="maven.test.classpath">
+                                    <arg value="--plugin" />
+                                    <arg value="json:${project.build.directory}/cucumber-no-clobber.json" />
+                                    <arg value="--glue" />
+                                    <arg value="domainapp.webapp.bdd.stepdefs" />
+                                    <arg value="${project.build.directory}/test-classes/domainapp/webapp/bdd/specs" />
+                                </java>
+                            </target>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <groupId>net.masterthought</groupId>
                 <artifactId>maven-cucumber-reporting</artifactId>
                 <version>${maven-cucumber-reporting.version}</version>
                 <executions>
                     <execution>
-                        <id>execution</id>
-                        <phase>verify</phase>
+                        <id>default</id>
+                        <phase>post-integration-test</phase>
                         <goals>
                             <goal>generate</goal>
                         </goals>
@@ -65,9 +96,9 @@
                             <outputDirectory>${project.build.directory}</outputDirectory>
                             <inputDirectory>${project.build.directory}</inputDirectory>
                             <jsonFiles>
-                                <param>**/cucumber.json</param>
+                                <param>**/cucumber-no-clobber.json</param>
                             </jsonFiles>
-                            <skip>${skipBSs}</skip>
+                            <skip>${skipBDD}</skip>
                         </configuration>
                     </execution>
                 </executions>
diff --git a/webapp/src/test/java/domainapp/webapp/bdd/RunCucumberSpecs.java b/webapp/src/test/java/domainapp/webapp/bdd/RunCucumberSpecs.java
new file mode 100644
index 0000000..4be4068
--- /dev/null
+++ b/webapp/src/test/java/domainapp/webapp/bdd/RunCucumberSpecs.java
@@ -0,0 +1,7 @@
+package domainapp.webapp.bdd;
+
+import io.cucumber.junit.platform.engine.Cucumber;
+
+@Cucumber
+public class RunCucumberSpecs {
+}
diff --git a/webapp/src/test/java/domainapp/webapp/bdd/RunIntegBddSpecs.java b/webapp/src/test/java/domainapp/webapp/bdd/RunIntegBddSpecs.java
deleted file mode 100644
index f61b05d..0000000
--- a/webapp/src/test/java/domainapp/webapp/bdd/RunIntegBddSpecs.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package domainapp.webapp.bdd;
-
-import org.junit.runner.RunWith;
-
-import io.cucumber.junit.Cucumber;
-import io.cucumber.junit.CucumberOptions;
-
-/**
- * Runs scenarios in all <tt>.feature</tt> files (this package and any subpackages). 
- */
-@RunWith(Cucumber.class)
-@CucumberOptions(
-        plugin = {
-                "html:target/cucumber-html-report"
-                ,"json:target/cucumber.json"
-        },
-        strict = true,
-        tags = { "not @backlog", "not @ignore" },
-        glue = {
-        },
-        features = {
-        }
-)
-public class RunIntegBddSpecs {
-    // intentionally empty 
-}
diff --git a/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/SimpleObjectsStepDef.java b/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/domain/SimpleObjectsStepDef.java
similarity index 97%
rename from webapp/src/test/java/domainapp/webapp/bdd/stepdefs/SimpleObjectsStepDef.java
rename to webapp/src/test/java/domainapp/webapp/bdd/stepdefs/domain/SimpleObjectsStepDef.java
index ef3fac0..bdb5b56 100644
--- a/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/SimpleObjectsStepDef.java
+++ b/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/domain/SimpleObjectsStepDef.java
@@ -1,4 +1,4 @@
-package domainapp.webapp.bdd.stepdefs;
+package domainapp.webapp.bdd.stepdefs.domain;
 
 import domainapp.modules.simple.dom.so.SimpleObject;
 import domainapp.modules.simple.dom.so.SimpleObjects;
diff --git a/webapp/src/test/java/domainapp/webapp/bdd/fixtures/DomainAppDemoStepDef.java b/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/fixtures/DomainAppDemoStepDef.java
similarity index 95%
rename from webapp/src/test/java/domainapp/webapp/bdd/fixtures/DomainAppDemoStepDef.java
rename to webapp/src/test/java/domainapp/webapp/bdd/stepdefs/fixtures/DomainAppDemoStepDef.java
index b66da87..a4ee5ae 100644
--- a/webapp/src/test/java/domainapp/webapp/bdd/fixtures/DomainAppDemoStepDef.java
+++ b/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/fixtures/DomainAppDemoStepDef.java
@@ -1,4 +1,4 @@
-package domainapp.webapp.bdd.fixtures;
+package domainapp.webapp.bdd.stepdefs.fixtures;
 
 import java.util.List;
 import java.util.UUID;
diff --git a/webapp/src/test/java/domainapp/webapp/bdd/infrastructure/BootstrapStepDef.java b/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/infrastructure/BootstrapStepDef.java
similarity index 90%
rename from webapp/src/test/java/domainapp/webapp/bdd/infrastructure/BootstrapStepDef.java
rename to webapp/src/test/java/domainapp/webapp/bdd/stepdefs/infrastructure/BootstrapStepDef.java
index b69042a..13e2230 100644
--- a/webapp/src/test/java/domainapp/webapp/bdd/infrastructure/BootstrapStepDef.java
+++ b/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/infrastructure/BootstrapStepDef.java
@@ -1,4 +1,4 @@
-package domainapp.webapp.bdd.infrastructure;
+package domainapp.webapp.bdd.stepdefs.infrastructure;
 
 import javax.inject.Inject;
 
diff --git a/webapp/src/test/java/domainapp/webapp/bdd/infrastructure/TransactionalStepDef.java b/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/infrastructure/TransactionalStepDef.java
similarity index 96%
rename from webapp/src/test/java/domainapp/webapp/bdd/infrastructure/TransactionalStepDef.java
rename to webapp/src/test/java/domainapp/webapp/bdd/stepdefs/infrastructure/TransactionalStepDef.java
index 6c35809..e39a52e 100644
--- a/webapp/src/test/java/domainapp/webapp/bdd/infrastructure/TransactionalStepDef.java
+++ b/webapp/src/test/java/domainapp/webapp/bdd/stepdefs/infrastructure/TransactionalStepDef.java
@@ -1,4 +1,4 @@
-package domainapp.webapp.bdd.infrastructure;
+package domainapp.webapp.bdd.stepdefs.infrastructure;
 
 import java.util.List;
 import java.util.UUID;
diff --git a/webapp/src/test/java/domainapp/webapp/bdd/specs/SimpleObjectSpec_listAllAndCreate.feature b/webapp/src/test/resources/domainapp/webapp/bdd/specs/SimpleObjectSpec_listAllAndCreate.feature
similarity index 100%
rename from webapp/src/test/java/domainapp/webapp/bdd/specs/SimpleObjectSpec_listAllAndCreate.feature
rename to webapp/src/test/resources/domainapp/webapp/bdd/specs/SimpleObjectSpec_listAllAndCreate.feature
diff --git a/webapp/src/test/resources/junit-platform.properties b/webapp/src/test/resources/junit-platform.properties
new file mode 100644
index 0000000..509256b
--- /dev/null
+++ b/webapp/src/test/resources/junit-platform.properties
@@ -0,0 +1,13 @@
+# as per https://github.com/cucumber/cucumber-jvm/tree/master/junit-platform-engine#configuration-options
+cucumber.filter.tags=not @backlog and not @ignore
+cucumber.glue=domainapp.webapp.bdd.stepdefs
+
+# WARNING:
+#
+# cucumber.plugins=json:target/cucumber.json
+#
+# will cause an empty file to be created when running from mvn.
+#
+# this is why the maven configuration to execute cucumber using the CLI (antrun:run@cucumber-cli)
+# is configured to use --plugins json:target/cucumber-no-clobber.json, just in case.
+#
\ No newline at end of file