骆驼和黄瓜-Junit忽略@UseAdviceWith

时间:2018-07-25 10:26:39

标签: apache-camel cucumber cucumber-junit spring-camel camel-test

黄瓜@RunWith(Cucumber.class)在我的步骤类中忽略@UseAdviceWith。结果,骆驼上下文始终启动,我无法控制何时启动。

要克服这一点,我要做:

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {"pretty", "html:target/cucumber"},
        features = {"blabla/feature"},
        glue = {"blabla.steps"})
public class TestRunner
{
  @BeforeClass
  public static void setUp()
  {
    SpringCamelContext.setNoStart(true);
  }
}

@Slf4j
//@UseAdviceWith - Ignored by Cucumber
@RunWith(CamelSpringBootRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class BlablaSteps {

  @Before()
  public void beforeScenario(Scenario scenario) throws Exception
  {
    SpringCamelContext.setNoStart(false);
    camelContext.start();
 }
}

有更好的方法吗?更具说明性?

我认为应该对此进行类似的测试,该测试使用Cucumber和@UseAdviceWith,手动启动骆驼上下文:https://github.com/apache/camel/blob/master/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java

依赖项:

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>2.4.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-spring</artifactId>
            <version>2.4.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>2.4.0</version>
            <scope>test</scope>
        </dependency>

和骆驼:

<camel-version>2.22.0</camel-version>

0 个答案:

没有答案