我正在尝试使用JUnit 5和Camel支持编写单元测试。
@Test
@ParameterizedTest(name = "Test case [{index}] name={3}")
@MethodSource("data")
@IfEnvProfile(profiles = {"preprod"}) (Customized Annotation)
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);
}
其中location.enricher.uri
- http://localhost/rating-service/api/v1/rate/d155446421121/location/(正在运行)。
但是当我运行它时,我总是在响应时收到Nullpointer
异常。
疑惑:
是否可以将A类中的JUnit 5和扩展为A类的CamelSupport
中的JUnit 4组合在一起?
我们对JUnit 5有CamelTestSupportClass
吗?
有人可以帮忙吗?
谢谢, Rajesh S
答案 0 :(得分:4)
org.apache.camel.test.junit4.CamelTestSupport
仅适用于JUnit 4。答案 1 :(得分:1)
当前Camel支持Junit5。您只需将其包含在pom.xml中
yourMethod(event: any) {
const controlName = e.target.getAttribute('formcontrolname');
this.formGroup.get(controlName); // this is your FormControl
....
}
并导入类:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-junit5</artifactId>
</dependency>
有关更多信息,请参见here。