spring-boot service层junit单元测试

只要加@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = StartupApplication.class)

两个注解就可以引入service进行单元测试了

 

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = StartupApplication.class)
public class OrderBookUserTest {

    @Autowired
    private OrderBookUserService orderBookUserService;
    
    
    @Test
    public void createOrderBook(){
//        System.out.println(userRepository);
        orderBookUserService.createOrderBook(5, 24, 1.5, 300 , 20, 1, OrderBookDirection.BUY);
    }
}

你可能感兴趣的:(spring-boot)