Spring boot test configuration

后端 未结 1 1740
野趣味
野趣味 2021-02-12 08:33

I have a spring boot application with main class like below:

@SpringBootApplication
public class Application {

    public static void main(String[] args) throws         


        
相关标签:
1条回答
  • 2021-02-12 09:18

    Something like that:

    @RunWith(SpringRunner.class)
    @SpringBootTest(classes = Application.class)
    public class ApplicationTest{
    
       @Autowired
       Foo foo; //whatever you are testing
    
       @Test
       public void FooTest() throws Exception{
         Foo f = foo.getFooById("22");
         assertEquals("9B", f.getCode); 
       }
     //TODO look into MockMVC for testing services
    }
    
    0 讨论(0)
提交回复
热议问题