i currently wonder what is the real difference between this snippet of code
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
public class TestClass1 {
// some code
}
ant this one..
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TestClass2 {
// some code
}
what can we do in the first code that can't do in the 2nd snippet ? and vice-versa : what can we do in the 2nd code that can't do in the 1rst snippet ?
for me, in both cases, we can :
so.. what is the difference ?
All that you need to know
@ExtendWith(SpringExtension.class)
@SpringBootTest
Use to run integration tests and load Spring TestContext
JUnit annotations are also available to use
Offer a rich API to configure test configuration
Recommended as it supports new features and is simple to use