Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. @RunWith(SpringJUnit4ClassRunner.class)
  2. @ContextConfiguration
  3. public class BaseTest {
  4. @Autowired
  5. MyComponent myComponent;
  6.  
  7. @Configuration
  8. @Import(MyComponentBaseConfiguration.class)
  9. static class Cfg {
  10. @Bean
  11. MyComponent myComponent() {
  12. return new MyComponent();
  13. }
  14. }
  15. void convert(MyComponentInterface component) {
  16. // here component is null
  17. }
  18. @Test
  19. public void test() {
  20. BaseTestChild child = new BaseTestChild();
  21. child.test();
  22. }
  23. }
  24.  
  25. @RunWith(SpringJUnit4ClassRunner.class)
  26. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  27. public class BaseTestChild extends BaseTest {
  28. @Test
  29. public void test() {
  30. convert(myComponent); // here myComponent is null
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement