vendredi 28 juillet 2017

Maven build not failing when gherkin tests fails

I have a maven project which executes some Gherkin files to do some tests, but when some of these tests fails maven doesn't care and succesfully complete the build.

My configuration is like:

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
}

Then my AppSpringIntegrationTests:

@ContextConfiguration(
    classes = AppFunctionalTestConfiguration.class,
    loader = SpringApplicationContextLoader.class
)
@IntegrationTest
public class AppSpringIntegrationTest {
      @Bean
      public FileStorageService fileStorageClient() {
         return new FileStorageServiceMock();
      }
      //...all the other beans
}

And then the cucumber configuration class:

@RunWith(Cucumber.class)
@CucumberOptions(
    features = "src/test/resources/functional/features",
    format = {"pretty", "html:target/cucumber"}
)
public class CucumberTest {
}

All the tests get executed but when they fail:

 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] ------------------------------------------------------------------------

Aucun commentaire:

Enregistrer un commentaire