@TestMethodOrder(OrderAnnotation.class)
@SpringJUnitWebConfig(locations = { "classpath:service.xml","classpath:data.xml" })
@Tag("1")
public @interface TransactionalIntegrationTest {}
@TransactionalIntegrationTest
public class MyTestTest {
@Autowired
protected CreateUser createUser;
@BeforeEach
public void setUp() throws Exception {
createUser.createTimesheetUser(...)} --> NPE
}
Getting NullPointerException on createUser
.
If I do not use the meta annotations, then it works fine.
@TestMethodOrder(OrderAnnotation.class)
@SpringJUnitWebConfig(locations = { "classpath:service.xml","classpath:data.xml" })
@Tag("1")
public class MyTestTest {
@Autowired
protected CreateUser createUser;
@BeforeEach
public void setUp() throws Exception {
createUser.createTimesheetUser(...)} --> works now
}
You're probably missing the @Retention
declaration which allows frameworks like Spring and JUnit to see the annotations at runtime.
Declaring your composed annotation as follows should work.
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@TestMethodOrder(OrderAnnotation.class)
@SpringJUnitWebConfig(locations = { "classpath:service.xml", "classpath:data.xml" })
@Tag("1")
public @interface TransactionalIntegrationTest {
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.