How not to start the program during the SpringBootTest test?

when I was testing with SpringBootTest, I found that the program would be started, causing the console test results to be flooded by the program output, and it would take time and resources to start the program. Is there any way to do SpringBootTest testing without starting the program?

in my test program, I will add the following comments

@ RunWith (SpringJUnit4ClassRunner.class)
@ SpringBootTest (classes = MainApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

it feels like starting the program because there is classes = MainApplication.class
but if you don"t add it, you can"t find other bean injections to be used

Jun.01,2022

the unit test itself does not rely on manual viewing of console output
requires bean, of course, spring
and, the output initiated by spring and the output of a single @ Test can be seen separately


if it is a Web application, the test class can write:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = MockServletContext.class)
@WebAppConfiguration
public class UserControllerTest {

    private MockMvc mockMvc;

    @Before
    public void before() {
        this.mockMvc = MockMvcBuilders.standaloneSetup(new UserController()).build();
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32b9f-2b5b4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32b9f-2b5b4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?