我有一个maven项目执行一些Gherkin文件来做一些测试,但是当其中一些测试失败时,maven并不关心并成功完成构建。
我的配置如下:
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
}
然后是黄瓜配置类:
@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>