1. 程式人生 > >spring-boot service層junit單元測試

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);
    }
}