#Spring Boot test does not run, only starts the application

1 messages · Page 1 of 1 (latest)

sage hare
#

I'm writing a simple integration test:

@SpringBootTest(classes = StoreApplication.class)
@RunWith(SpringRunner.class)
public class DefaultCreateOrderUseCaseTests {
    @Autowired
    BatchCrudPort batchCrudPort;
    
// Some other autowired dependencies

  @Test
  public void test() {
    Assert.assertTrue(true)
  }

}

When I run it (using IntelliJ's built-in button) the application starts, but my test is not ran. Without the @RunWith annotation, my autowired dependencies remain null, which is weird, because I thought the point of the @SpringBootTest annotation is that I have access to the application context.
Any ideas?

mighty pulsarBOT
#

<@&1004656351647117403> please have a look, thanks.

mighty pulsarBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

sage hare
#

I would expect to see the test succeed, then the application stop.

#

What am I missing?

sudden hedge
#

@hollow cryptWith is junit4 which is kinda old, still used, but old
Might be you need to use @ExtendWith(SpringExtension.class)