Java 当小黄瓜测试失败时,Maven构建不会失败
我有一个maven项目,它执行一些小黄瓜文件来做一些测试,但是当其中一些测试失败时,maven并不在意并成功地完成了构建 我的配置如下:Java 当小黄瓜测试失败时,Maven构建不会失败,java,maven,testing,cucumber,gherkin,Java,Maven,Testing,Cucumber,Gherkin,我有一个maven项目,它执行一些小黄瓜文件来做一些测试,但是当其中一些测试失败时,maven并不在意并成功地完成了构建 我的配置如下: public class AppStepDefs extends AppSpringIntegrationTest { @Autowired ContentServiceMock contentMock; @Autowired FileStorageServiceMock fileStorageMock; @Give
public class AppStepDefs extends AppSpringIntegrationTest {
@Autowired
ContentServiceMock contentMock;
@Autowired
FileStorageServiceMock fileStorageMock;
@Given("^following stuff are stored in content service$")
public void given_following_stuff(DataTable dataTable) {
dataTable.asMaps(String.class, String.class)
.stream()
.map(StuffConverter::fromDataTableRow)
.forEach(stuff -> contentMock.insert(stuff.get("id").toString(), stuff));
}
//...all the other steps
}
然后我的AppSpringIntegrationTests
:
@ContextConfiguration(
classes = AppFunctionalTestConfiguration.class,
loader = SpringApplicationContextLoader.class
)
@IntegrationTest
public class AppSpringIntegrationTest {
@Bean
public FileStorageService fileStorageClient() {
return new FileStorageServiceMock();
}
//...all the other beans
}
然后是cucumber配置类:
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/resources/functional/features",
format = {"pretty", "html:target/cucumber"}
)
public class CucumberTest {
}
所有测试都会执行,但失败时:
Failed scenarios:
cucumber_conf.feature:12 # Scenario: Test creation with stuff
22 Scenarios (1 failed, 21 passed)
65 Steps (1 failed, 64 passed)
0m12,586s
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 17.866 sec - in TestSuite
Results :
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] StuffService Parent ............ SUCCESS [ 1.012 s]
[INFO] StuffService ................... SUCCESS [ 22.588 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.992 s
[INFO] Finished at: 2017-07-28T14:46:35+02:00
[INFO] Final Memory: 60M/419M
[INFO] ------------------------------------------------------------------------
以下是我正在使用的黄瓜依赖项:
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-spring</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
信息杯
黄瓜爪哇
1.2.4
测试
信息杯
黄瓜之春
1.2.4
测试
信息杯
黄瓜试验
1.2.4
测试
您能提供pom.xml文件吗?我没有pom中测试的任何特定配置,我没有声明surefire插件或failsafe…(我不知道是否可以公开发布pom.xml)我在问题中添加了CucumberTest文件位于何处?与其他文件位于同一个包中…目前我还解决了从junit更改为TestNG的问题。您可以提供pom.xml文件吗?我没有pom中测试的任何特定配置,我没有声明surefire插件或故障保护。。。(我不知道是否可以公开发布pom.xml)我已经在问题CucumberTest文件位于何处?与其他文件在同一个包中添加了cucumber依赖项…目前我还解决了从junit更改为testng的问题