Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use spock in springboot

Shulou Source: shulou.com Published: 2022-06-02 07:30:51 10月02日 Update

This article introduces how to use spock in springboot, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Earlier, I introduced the detailed use of the spock test framework and how to use test piles in spock. This article introduces the use of spock in a springboot environment.

Using spock in the spring environment, that is, injecting the tested instance automatically, does not require us to initialize the instance manually.

This means starting the spring container and then running our test cases, which is easy to do in springboot, even simpler than junit. As follows:

Package com.yawn.spockimport com.yawn.spock.service.CalculateServiceimport org.springframework.beans.factory.annotation.Autowiredimport org.springframework.boot.test.context.SpringBootTestimport spock.lang.Specification@SpringBootTestclass SpringBootSpec extends Specification {@ Autowired CalculateService calculateService; def "spring boot test" () {expect: "asas" z = = calculateService.minus (x, y) where: X

Tags: Testing that is content examples more environment help good interests containers guys buddies manual articles frames knowledge articles references run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux Shulou Information vpn macOS