Тесты Maven не запускают сценарий огурца ios с Spring Boot 2.2 и JUnit 5 - PullRequest
1 голос
/ 02 апреля 2020

Я пробую JUnit 5 и Cucumber при Spring Boot 2.2.6, и мне понадобятся и BDD scenar ios, и юнит-тесты в моем приложении. Я создал фиктивный контроллер ping, соответствующий файлу функций, которые в порядке.

Тесты на огурец не запускаются при запуске mvn clean test. Только тест JUnit называется. Тем не менее, я могу запустить Cucumber Scenar ios из Intellij GUI, если нажать кнопку Run Test для CucumberTest.java.

Вот мои уроки:

DummyApplicationTests.java:

package com.a.dummy;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@ActiveProfiles("test")
public class DummyApplicationTests {

    @Test
    public void contextLoads() {
    }

}

CucumberTest.java:

package com.a.dummy.bdd;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features")
public class CucumberTest {
}

CucumberSpringContextConfiguration.java:

package com.a.dummy.bdd;

import com.a.dummy.DummyApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@ContextConfiguration(classes = DummyApplication.class)
public abstract class CucumberSpringContextConfiguration {

}

PingTest.java:

package com.a.dummy.bdd.steps;

import com.a.dummy.bdd.CucumberSpringContextConfiguration;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

public class PingTest extends CucumberSpringContextConfiguration {

    @When("^the client calls /ping")
    public void the_client_issues_GET_ping() {
        ...
    }

    @Then("^the client receives status code of (\\d+)$")
    public void the_client_receives_status_code_of(int statusCode) {
        ...
    }

    @And("^the client receives ping response")
    public void the_client_receives_ping_response_body() {
       ...
    }
}

Чего мне не хватает?

1 Ответ

0 голосов
/ 10 апреля 2020

Поддержка JUnit 5 еще не интегрирована, и мне пришлось включить junit-vintage, потому что RunWith - это аннотация Junit 4.

...