具有CamelTestSupport的Junit 5

Raj*_*esh 2 spring-boot junit5

我正在尝试使用JUnit 5和Camel支持编写单元测试。

  1. JUnit 5(5.0.0)在类A中使用以下注释@方法级别:
@Test
@ParameterizedTest(name = "Test case [{index}] name={3}")
@MethodSource("data")
@IfEnvProfile(profiles = {"preprod"}) (Customized Annotation)
Run Code Online (Sandbox Code Playgroud)
  1. A类扩展了使用Junit 4的CamelTestSupport,尝试使用以下代码访问服务:
protected ResponseDto  getReponse(String testFile) throws Exception {
    Transaction tx= new Transaction ();
    final Map<String,Object> headers= setAllHeader(tx);
    // enter code here
    ResponseDto response =
        (RatingResponseDto) template.sendBodyAndHeaders("{{.location.enricher.uri}}",
            ExchangePattern.InOut, tx, headers);
}
Run Code Online (Sandbox Code Playgroud)

其中location.enricher.uri- HTTP://本地主机/评级服务/ API / V1 /速度/ d155446421121 /位置/(启动和运行)。

但是当我运行它时,我总是会Nullpointer在响应时收到异常。

疑问:

  1. 是否可以将A类中的JUnit 5和CamelSupport扩展了A 类的JUnit 4组合在一起?

  2. 我们有CamelTestSupportClassJUnit 5吗?

有人可以帮忙吗?

谢谢,Rajesh S

Jos*_*elo 6

目前 Camel 支持 Junit 5。您只需将其包含在 pom.xml 中

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-test-junit5</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)

并导入类:

import org.apache.camel.test.junit5.CamelTestSupport;
Run Code Online (Sandbox Code Playgroud)

浏览此处获取更多信息。


Sam*_*nen 5

  1. 否:该类org.apache.camel.test.junit4.CamelTestSupport仅适用于JUnit 4。
  2. 编号:骆驼还没有对JUnit的木星(即JUnit的5)的支持,但他们有一个悬而未决的问题在以后的版本中增加这样的支持。