springboot + junit4 how to use unit tests?

1. New Test class. If use idea, shortcut keys can be used to generate alt + insert.

2. Test class plus two notes:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)

Other tests may also be inherited class has two annotations.

3. Add the test method, the name easily play, such as public void test () {}, together with the comment:

@Test

4. bean injection required.

Guess you like

Origin www.cnblogs.com/longmenzhitong/p/11116269.html