2
私は春の注釈に問題があります。私がしたいのは、共通の設定を持つ1つのアノテーションに必要なテストアノテーションをすべて取得することです。また、Spring Contextが起動するとnullポインタ例外が発生します(豆をオートワイヤできません)。デザインでカスタムアノテーションで@ContextConfigurationを組み合わせることはできませんので、私は@MyTestAnnotationsから設定を使用したい別々の注釈で構成の注釈をテストします
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD,ElementType.TYPE})
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = { JPAConfig.class, AOPConfiguration.class })
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class })
public @interface MyTestAnnotations {
}
とテストケースが
@MyTestAnnotations
public class AspectTest {
@Autowired
PagingAndSortingBookRepository pagingAndSortingRepo;
@Autowired
SmartLoggerAspect smartLoggerAspect;
JoinPoint joinPoint;
// other methods
@Test
public void pagingTest(){
// line below throws nullPointerException
pagingAndSortingRepo.findAll(new PageRequest(1, 1));
}
}
ようなものを使用することができるはずです。 Thans! –
私はなぜこの男がちょうどそこで起こるかわからない: https://youtu.be/5tgkxGEvK4U?t=2228 –
@PrzemysławSienkiewiczはい。私にもちょっと不思議に思ってください。私はこれが実際にうまくいくかどうかはわかりません。とにかく共有してくれてありがとう – kuhajeyan