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

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


The following commit(s) were added to refs/heads/maint-1.16.1 by this push:
     new aea06a1  ISIS-1820: fixes BDD tests in simpleapp example application
aea06a1 is described below

commit aea06a15815bab3a2615e83733de449c875f820d
Author: Dan Haywood <d...@haywood-associates.co.uk>
AuthorDate: Fri Feb 9 12:36:00 2018 +0000

    ISIS-1820: fixes BDD tests in simpleapp example application
---
 ..._ugfun_getting-started_simpleapp-archetype.adoc |  2 +-
 ..._ugtst_bdd-spec-support_writing-a-bdd-spec.adoc | 26 ++++++++++++++++++----
 ...gtst_fixture-scripts_ticking-clock-fixture.adoc |  2 +-
 .../core/specsupport/specs/CukeGlueAbstract2.java  |  3 ++-
 .../specs/CukeGlueBootstrappingAbstract.java       | 10 +++++++++
 .../bdd/specglue/BootstrappingGlue.java            | 16 +++++++++++--
 .../{RunBddSpecs.java => RunIntegBddSpecs.java}    |  2 +-
 7 files changed, 51 insertions(+), 10 deletions(-)

diff --git 
a/adocs/documentation/src/main/asciidoc/guides/ugfun/_ugfun_getting-started_simpleapp-archetype.adoc
 
b/adocs/documentation/src/main/asciidoc/guides/ugfun/_ugfun_getting-started_simpleapp-archetype.adoc
index 8ff4165..7fd75ea 100644
--- 
a/adocs/documentation/src/main/asciidoc/guides/ugfun/_ugfun_getting-started_simpleapp-archetype.adoc
+++ 
b/adocs/documentation/src/main/asciidoc/guides/ugfun/_ugfun_getting-started_simpleapp-archetype.adoc
@@ -221,7 +221,7 @@ The BDD specs (run using Cucumber) reside under 
`domain.application.bdd`:
 >>>>> SimpleObjectSpec_listAllAndCreate.feature
 ----
 
-Here the `BootstrappingGlue` glue class inherits from the framework's 
`CukeGlueBootstrappingAbstract` class, and bootstraps using the 
`DomainAppApplicationModule` mentioned above.
+Here the `BootstrappingGlue` glue class inherits from the framework's 
`HeadlessWithBootstrappingAbstract` class, and bootstraps using the 
`DomainAppApplicationModule` mentioned above.
 
 There is just one feature file: `SimpleObjectSpec_listAllAndCreate.feature`, 
which is pretty simple:
 
diff --git 
a/adocs/documentation/src/main/asciidoc/guides/ugtst/_ugtst_bdd-spec-support_writing-a-bdd-spec.adoc
 
b/adocs/documentation/src/main/asciidoc/guides/ugtst/_ugtst_bdd-spec-support_writing-a-bdd-spec.adoc
index b639fd8..3c60d3d 100644
--- 
a/adocs/documentation/src/main/asciidoc/guides/ugtst/_ugtst_bdd-spec-support_writing-a-bdd-spec.adoc
+++ 
b/adocs/documentation/src/main/asciidoc/guides/ugtst/_ugtst_bdd-spec-support_writing-a-bdd-spec.adoc
@@ -76,15 +76,33 @@ The bootstrapping of Apache Isis itself lives in a 
`BootstrappingGlue` step defi
 
 [source,java]
 ----
-public class BootstrappingGlue extends CukeGlueBootstrappingAbstract {  // <1>
+public class BootstrappingGlue
+                extends HeadlessWithBootstrappingAbstract { // <1>
+
     public BootstrappingGlue() {
-        super(new DomainAppApplicationModule());                        // <2>
+        super(new DomainAppApplicationModule());            // <2>
+    }
+
+    @Before(order=100)                                      // <3>
+    public void beforeScenario() {
+        super.bootstrapAndSetupIfRequired();
+    }
+    @After
+    public void afterScenario(cucumber.api.Scenario sc) {
+        super.tearDownAllModules();
     }
 }
 ----
-<1> superclass contains the bootstrapping logic.
-This reuses many of the same classes as the integration testing framework
+<1> superclass contains much of the bootstrapping logic (and is also used by 
the integration testing framework)
 <2> the `Module` to use to bootstrap the application in headless mode.
+<3> remainder of the class is just boilerplate.
+
+[NOTE]
+====
+For BDD specs, the `CukeGlueBootstrappingAbstract` was previously provided (as 
a BDD counterpart to `IntegrationTestAbstract3`) to perform the relevant 
bootstrapping.
+_However_, it turns out that Cucumber does not allow subclassing of BDD specs.
+Therefore the bootstrapping boilerplate (that ideally would have been factored 
out into an abstract superclass) must be included within the BDD spec.
+====
 
 The fixture to run also lives in its own step definition, 
`CatalogOfFixturesGlue`:
 
diff --git 
a/adocs/documentation/src/main/asciidoc/guides/ugtst/_ugtst_fixture-scripts_ticking-clock-fixture.adoc
 
b/adocs/documentation/src/main/asciidoc/guides/ugtst/_ugtst_fixture-scripts_ticking-clock-fixture.adoc
index fd82e9e..3778270 100644
--- 
a/adocs/documentation/src/main/asciidoc/guides/ugtst/_ugtst_fixture-scripts_ticking-clock-fixture.adoc
+++ 
b/adocs/documentation/src/main/asciidoc/guides/ugtst/_ugtst_fixture-scripts_ticking-clock-fixture.adoc
@@ -20,5 +20,5 @@ executionContext.executeChild(this, new 
TickingClockFixture().setTo("2014-09-03"
 A variety of format strings are supported; the format "YYYY-MM-DD" (as shown 
above) will work in every locale.
 
 The fixture script requires that a `TickingFixtureClock` is initialized during 
bootstrapping.
-This is done automatically `IntegrationTestAbstract3` and 
`CukeGlueBootstrappingAbstract` (BDD specs).
+This is done automatically in `HeadlessWithBootstrappingAbstract` (the 
superclass of `IntegrationTestAbstract3` and for BDD bootstrapping classes).
 
diff --git 
a/core/specsupport/src/main/java/org/apache/isis/core/specsupport/specs/CukeGlueAbstract2.java
 
b/core/specsupport/src/main/java/org/apache/isis/core/specsupport/specs/CukeGlueAbstract2.java
index 01b95a3..528d463 100644
--- 
a/core/specsupport/src/main/java/org/apache/isis/core/specsupport/specs/CukeGlueAbstract2.java
+++ 
b/core/specsupport/src/main/java/org/apache/isis/core/specsupport/specs/CukeGlueAbstract2.java
@@ -22,7 +22,8 @@ import org.apache.isis.core.runtime.headless.HeadlessAbstract;
  * Base class for BDD spec glue.
  *
  * <p>
- *     Note that there also needs to be at least one spec glue that inherits 
from{@link CukeGlueBootstrappingAbstract}.
+ *     Note that there also needs to be at least one spec glue that performs 
the bootstrapping.
+ *     inherits from{@link CukeGlueBootstrappingAbstract}.
  * </p>
  */
 public abstract class CukeGlueAbstract2 extends HeadlessAbstract {
diff --git 
a/core/specsupport/src/main/java/org/apache/isis/core/specsupport/specs/CukeGlueBootstrappingAbstract.java
 
b/core/specsupport/src/main/java/org/apache/isis/core/specsupport/specs/CukeGlueBootstrappingAbstract.java
index 0ca1e90..e5e21e2 100644
--- 
a/core/specsupport/src/main/java/org/apache/isis/core/specsupport/specs/CukeGlueBootstrappingAbstract.java
+++ 
b/core/specsupport/src/main/java/org/apache/isis/core/specsupport/specs/CukeGlueBootstrappingAbstract.java
@@ -25,7 +25,17 @@ import cucumber.api.java.Before;
 /**
  * For BDD spec using headless access, there needs to be (at least) one BDD 
spec glue that inherits from this adapter
  * class, specifying the {@link Module} to use to bootstrap the system.
+ *
+ * <p>
+ *     <b>This class is deprecated</b>.  it's not possible to subclass from 
this class, it'll result in an exception:
+ *     <code>cucumber.runtime.CucumberException: You're not allowed to extend 
classes that define Step Definitions or
+ *     hooks</code>.
+ *     Instead, just inline the contents of this class.
+ * </p>
+ *
+ * @deprecated - it's not possible to subclass from this class, Instead, just 
inline the contents of this class.
  */
+@Deprecated
 public abstract class CukeGlueBootstrappingAbstract extends 
HeadlessWithBootstrappingAbstract {
 
     protected CukeGlueBootstrappingAbstract(final Module module) {
diff --git 
a/example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specglue/BootstrappingGlue.java
 
b/example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specglue/BootstrappingGlue.java
index 7988f2f..654d555 100644
--- 
a/example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specglue/BootstrappingGlue.java
+++ 
b/example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specglue/BootstrappingGlue.java
@@ -16,11 +16,23 @@ O *  Licensed to the Apache Software Foundation (ASF) under 
one or more
  */
 package domainapp.application.bdd.specglue;
 
-import org.apache.isis.core.specsupport.specs.CukeGlueBootstrappingAbstract;
+import org.apache.isis.core.runtime.headless.HeadlessWithBootstrappingAbstract;
 
+import cucumber.api.java.After;
+import cucumber.api.java.Before;
 import domainapp.application.DomainAppApplicationModule;
 
-public class BootstrappingGlue extends CukeGlueBootstrappingAbstract {
+public class BootstrappingGlue extends HeadlessWithBootstrappingAbstract {
+
+    @Before(order=100)
+    public void beforeScenario() {
+        super.bootstrapAndSetupIfRequired();
+    }
+
+    @After
+    public void afterScenario(cucumber.api.Scenario sc) {
+        super.tearDownAllModules();
+    }
 
     public BootstrappingGlue() {
         super(new DomainAppApplicationModule());
diff --git 
a/example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunBddSpecs.java
 
b/example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunIntegBddSpecs.java
similarity index 97%
rename from 
example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunBddSpecs.java
rename to 
example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunIntegBddSpecs.java
index b507749..77e5a5e 100644
--- 
a/example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunBddSpecs.java
+++ 
b/example/application/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunIntegBddSpecs.java
@@ -38,6 +38,6 @@ import cucumber.api.junit.Cucumber;
         strict = true,
         tags = { "~@backlog", "~@ignore" }
 )
-public class RunBddSpecs {
+public class RunIntegBddSpecs {
     // intentionally empty 
 }

-- 
To stop receiving notification emails like this one, please contact
danhayw...@apache.org.

Reply via email to