download: Core technologies for Spring Boot2.0 deep practices

The course systematically and deeply discusses the core features of Spring Boot, guides students to pay attention to Java specifications, inspires them to think about technical principles, master the skills of troubleshooting problems, and learn the methods and skills of reading source code, comprehensively improve their research and development ability, and join the team of architects.

Suits the crowd

1~5 years development experience, middleware developer, system architect

Technical reserve requirements

Basic knowledge of Spring Framework or Spring Boot

Testng testng 6.8.8 test There are two ways to use DataProvider to provide data: Put test code and test data in the same class; Having all the data provided in a single class makes it easier to maintain when the test data is large. Use 1. Regular use import org. Testng. Annotations. The DataProvider. import org.testng.annotations.Test; public class ParamTestWithDataProvider1 { @DataProvider(name = "test1") public static Object[][] primeNumbers() { return  new Object[][] { { 2, true ,"hi"}, { 6, false ,"test"}, { 19, true ,"good"}, { 22, false ,"aha"}, { 23, true ,"loo"} }; @test (dataProvider = "test1") public void testPrimeNumberChecker(Integer inputNumber, Boolean expectedResult, String test) { System.out.println(inputNumber + " " + expectedResult+" "+test); If you want DataProvider to use different dataProviders for different Test methods, you can use different dataProviders for different Test methods. So can use in your DataProvider Method parameter import org. The testng. Annotations. The DataProvider. import org.testng.annotations.Test; import java.lang.reflect.Method; public class ParamTestWithDataProvider2 { @Test(dataProvider = "provider") public void getFirst(String name, Int age) {system.out.println (" first group "+name); } @test (dataProvider = "provider") public void getSecond(String name, int age) {system.out.println (" dataProvider "+ name); } @DataProvider(name = "provider") public Object[][] provider(Method method) { Object[][] objects; If (method.getName().equals("getFirst")) {// Call the DataProvider function getFirst, Objects = new Object[][] {{"cq2", 20}, {"cq2", 22}}; } else if (method.getName().equals("getSecond")) {// If the DataProvider is called with getSecond, Objects = new Object[][] {{"cq3", 20}, {"cq4", 22}}; } else {// If the DataProvider function is not getFirst or getSecond, then return the array objects = new Object[][] {{"cq5",33}, {"cq6",34}}; } return objects; }} 3. After DataProviderClass to guide test data file to import org. The testng. Annotations. The DataProvider; Public class DataProviderMethod {// No specified data title, @dataProvider public static Object[][] NoNameMethod(){return new Object[][]{{"DataWithNoName1"}, {"DataWithNoName2"}, {"DataWithNoName3"} }; @dataProvider (name=" dataProvider1 ") public static Object[][] dataProvider1(){return new Object[][]{ {"dataprovider1-1"}, {"dataprovider1-2"} }; @dataProvider (name=" dataProvider2 ") public static Object[][] dataProvider2(){return new Object[][]{ {"dataprovider2-1"}, {"dataprovider2-2"} }; } } import org.testng.annotations.Test; public class ParamTestWithDataProvider3 { @Test(dataProvider="NoNameMethod",dataProviderClass=DataProviderMethod.class) Public void doTestNG(String testDatas) {system.out.println (" not specified, data source NoNameMethod:"+ testDatas); } @ Test(dataProvider="dataprovider1",dataProviderClass=DataProviderMethod.class) public void doTestNG1(String Testdatas){system.out.println (" specify title, data source title select dataprovider1:"+ testDatas); } @Test(dataProvider="dataprovider2",dataProviderClass=DataProviderMethod.class) public void doTestNG2(String Testdatas){system.out.println (" specify title, data source title select dataprovider2:"+ testDatas); }}Copy the code