Commit 3a3a3c4f authored by 技术部-任文超's avatar 技术部-任文超

提交jUnit测试Demo

parent 7c09b21d
package demo;
import cn.quantgroup.xyqb.Bootstrap;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.junit.Assert;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Bootstrap.class)
@WebAppConfiguration
public class DemoApplicationTests {
@ParameterizedTest
@ValueSource(strings = { "racecar", "radar", "able was I ere I saw elba" })
void palindromes(String candidate) {
Assert.assertNotNull(candidate);
}
@Ignore("Not Ready to Run")
@Test
public void loginFast() {
}
}
......@@ -19,6 +19,12 @@ import java.util.stream.Stream;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.function.ThrowingConsumer;
/**
* 动态批量测试
* @author renwc
* @date 2018-01-05
*/
@Tag("Test Factory")
public class DynamicTests {
......
package demo;
import org.junit.Ignore;
import org.junit.jupiter.api.DisplayName;
import org.junit.Test;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* jUnit4风格参数化批量测试(用例)
* @author renwc
* @date 2018-01-05
*/
@Tag("Parameters")
@RunWith(value = Parameterized.class)
public class ParametersTest {
public class ParametersJunit4Tests {
private String key;
private int value;
public ParametersTest(String key, int value) {
public ParametersJunit4Tests(String key, int value) {
this.key = key;
this.value = value;
}
@Parameterized.Parameters
public Collection<Object[]> data() {
public static Collection<Object[]> data() {
Object[][] data = new Object[][] {{"1", 1}, {"2", 2}, {"3", 3}, {"4", 4}};
return Arrays.asList(data);
}
......@@ -34,12 +34,4 @@ public class ParametersTest {
System.out.println("Parameterized is : key="+ key+", value="+value);
}
// @Ignore("Not Ready to Run")
// @Test
// @DisplayName("My 1st JUnit 5 test! 😎")
// void myFirstTest(TestInfo testInfo) {
// assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
// assertEquals("My 1st JUnit 5 test! 😎", testInfo.getDisplayName(), () -> "TestInfo is injected correctly");
// }
}
\ No newline at end of file
package demo;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* jUnit5风格参数化批量测试(用例)
* @author renwc
* @date 2018-01-05
*/
@Tag("Parameters")
public class ParametersJunit5Tests {
@ParameterizedTest
@ValueSource(strings = { "racecar", "radar", "able was I ere I saw elba" })
void palindromes(String candidate) {
Assert.assertNotNull(candidate);
}
@Ignore("Not Ready to Run")
@Test
public void loginFast() {
System.out.println("Not Ready to Run");
}
@Ignore("Not Ready to Run")
@DisplayName("My 1st JUnit 5 test! 😎")
@org.junit.jupiter.api.Test
public void myFirstTest(TestInfo testInfo) {
assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
assertEquals("My 1st JUnit 5 test! 😎", testInfo.getDisplayName(), () -> "TestInfo is injected correctly");
}
}
\ No newline at end of file
app.id=xyqb-user2
namespace=application
\ No newline at end of file
namespace=application,tech.msg.sdk,tech.sleuth,tech.common,tech.service.urls,cash.common
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment