You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ag...@apache.org on 2013/05/05 20:39:57 UTC
git commit: o Add an IT for using the Cucumber runner with the
junit47 provider
Updated Branches:
refs/heads/master 72893fed6 -> 37fba0f87
o Add an IT for using the Cucumber runner with the junit47 provider
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/37fba0f8
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/37fba0f8
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/37fba0f8
Branch: refs/heads/master
Commit: 37fba0f87b760d24ff65ac19de3f943457559f4a
Parents: 72893fe
Author: Andreas Gudian <ag...@apache.org>
Authored: Sun May 5 20:39:21 2013 +0200
Committer: Andreas Gudian <ag...@apache.org>
Committed: Sun May 5 20:39:21 2013 +0200
----------------------------------------------------------------------
.../maven/surefire/its/Junit47WithCucumberIT.java | 58 ++++++++++
.../src/test/resources/junit47-cucumber/pom.xml | 81 +++++++++++++++
.../org/sample/cucumber/FailingCucumberTest.java | 31 ++++++
.../test/java/org/sample/cucumber/StepDefs.java | 57 ++++++++++
.../org/sample/cucumber/SuccessCucumberTest.java | 31 ++++++
.../src/test/resources/failing/Sample.feature | 10 ++
.../src/test/resources/success/Sample.feature | 10 ++
7 files changed, 278 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/37fba0f8/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47WithCucumberIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47WithCucumberIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47WithCucumberIT.java
new file mode 100644
index 0000000..b58ee46
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47WithCucumberIT.java
@@ -0,0 +1,58 @@
+package org.apache.maven.surefire.its;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Test;
+
+/**
+ * Tests the JUnit 47 provider with the cucumber runner. At the moment, they don't play along that perfectly (minor
+ * glitches in the reports with parallel=classes), but at least all tests are executed, the execution times are counted
+ * correctly and failing tests are reported. The main problem that the junit47 provider has with the cucumber runner is
+ * that the junit Description instance created by the runner has a null test class attribute.
+ *
+ * @author agudian
+ */
+public class Junit47WithCucumberIT
+ extends SurefireJUnit4IntegrationTestCase
+{
+
+ @Test
+ public void testWithoutParallel()
+ {
+ // 8 tests in total is what's probably correct
+ doTest( "none", 8 );
+ }
+
+ @Test
+ public void testWithParallelClasses()
+ {
+ // with parallel=classes, we get 9 tests in total,
+ // as the dummy "scenario" test entry is reported twice: once as success, and once with the failure from the
+ // failing test step
+ doTest( "classes", 9 );
+ }
+
+ private void doTest( String parallel, int total )
+ {
+ unpack( "junit47-cucumber" ).sysProp( "parallel", parallel ).executeTest().assertTestSuiteResults( total, 0, 2,
+ 0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/37fba0f8/surefire-integration-tests/src/test/resources/junit47-cucumber/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit47-cucumber/pom.xml b/surefire-integration-tests/src/test/resources/junit47-cucumber/pom.xml
new file mode 100644
index 0000000..a57d3c4
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit47-cucumber/pom.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>it-parent</artifactId>
+ <version>1.0</version>
+ </parent>
+
+ <artifactId>junit47-cucumber</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Tests cucumber with JUnit47 provider</name>
+
+ <properties>
+ <cucumber.version>1.1.3</cucumber.version>
+ <junit.version>4.11</junit.version>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkCount>0</forkCount>
+ <testFailureIgnore>true</testFailureIgnore>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit47</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>info.cukes</groupId>
+ <artifactId>cucumber-java</artifactId>
+ <version>${cucumber.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>info.cukes</groupId>
+ <artifactId>cucumber-junit</artifactId>
+ <version>${cucumber.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/37fba0f8/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/FailingCucumberTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/FailingCucumberTest.java b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/FailingCucumberTest.java
new file mode 100644
index 0000000..ed86734
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/FailingCucumberTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.sample.cucumber;
+
+import org.junit.runner.RunWith;
+
+import cucumber.api.junit.Cucumber;
+
+@RunWith( Cucumber.class )
+@Cucumber.Options( features = { "classpath:failing" } )
+public class FailingCucumberTest
+{
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/37fba0f8/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/StepDefs.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/StepDefs.java b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/StepDefs.java
new file mode 100644
index 0000000..ba25f69
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/StepDefs.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.sample.cucumber;
+
+import cucumber.api.java.en.Given;
+import cucumber.api.java.en.Then;
+import cucumber.api.java.en.When;
+
+import static org.junit.Assert.fail;
+
+public class StepDefs
+{
+ @Given( "^I have some code$" )
+ public void I_have_some_code()
+ throws Throwable
+ {
+ // do nothing
+ }
+
+ @When( "^I run test$" )
+ public void I_run_test()
+ throws Throwable
+ {
+ // do nothing
+ }
+
+ @Then( "^I get no failures$" )
+ public void I_get_no_failures()
+ throws Throwable
+ {
+ // do nothing
+ }
+
+ @Then( "^I get a failure$" )
+ public void I_get_a_failure()
+ throws Throwable
+ {
+ fail( "failing the test on purpose." );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/37fba0f8/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/SuccessCucumberTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/SuccessCucumberTest.java b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/SuccessCucumberTest.java
new file mode 100644
index 0000000..318f5e6
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/java/org/sample/cucumber/SuccessCucumberTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.sample.cucumber;
+
+import org.junit.runner.RunWith;
+
+import cucumber.api.junit.Cucumber;
+
+@RunWith( Cucumber.class )
+@Cucumber.Options( features = { "classpath:success" } )
+public class SuccessCucumberTest
+{
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/37fba0f8/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/resources/failing/Sample.feature
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/resources/failing/Sample.feature b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/resources/failing/Sample.feature
new file mode 100644
index 0000000..e8ac945
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/resources/failing/Sample.feature
@@ -0,0 +1,10 @@
+Feature: Sample
+
+ In order to use Maven
+ As a user
+ I want to do tests.
+
+ Scenario: Do a failing test
+ Given I have some code
+ When I run test
+ Then I get a failure
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/37fba0f8/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/resources/success/Sample.feature
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/resources/success/Sample.feature b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/resources/success/Sample.feature
new file mode 100644
index 0000000..26f0d2d
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit47-cucumber/src/test/resources/success/Sample.feature
@@ -0,0 +1,10 @@
+Feature: Sample
+
+ In order to use Maven
+ As a user
+ I want to do tests.
+
+ Scenario: Do a successful test
+ Given I have some code
+ When I run test
+ Then I get no failures