8 changed files with 303 additions and 287 deletions
@ -1,45 +1,45 @@ |
|||||
package org.dromara.test; |
//package org.dromara.test;
|
||||
|
//
|
||||
import org.junit.jupiter.api.Assertions; |
//import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName; |
//import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test; |
//import org.junit.jupiter.api.Test;
|
||||
|
//
|
||||
/** |
///**
|
||||
* 断言单元测试案例 |
// * 断言单元测试案例
|
||||
* |
// *
|
||||
* @author Lion Li |
// * @author Lion Li
|
||||
*/ |
// */
|
||||
@DisplayName("断言单元测试案例") |
//@DisplayName("断言单元测试案例")
|
||||
public class AssertUnitTest { |
//public class AssertUnitTest {
|
||||
|
//
|
||||
@DisplayName("测试 assertEquals 方法") |
// @DisplayName("测试 assertEquals 方法")
|
||||
@Test |
// @Test
|
||||
public void testAssertEquals() { |
// public void testAssertEquals() {
|
||||
Assertions.assertEquals("666", new String("666")); |
// Assertions.assertEquals("666", new String("666"));
|
||||
Assertions.assertNotEquals("666", new String("666")); |
// Assertions.assertNotEquals("666", new String("666"));
|
||||
} |
// }
|
||||
|
//
|
||||
@DisplayName("测试 assertSame 方法") |
// @DisplayName("测试 assertSame 方法")
|
||||
@Test |
// @Test
|
||||
public void testAssertSame() { |
// public void testAssertSame() {
|
||||
Object obj = new Object(); |
// Object obj = new Object();
|
||||
Object obj1 = obj; |
// Object obj1 = obj;
|
||||
Assertions.assertSame(obj, obj1); |
// Assertions.assertSame(obj, obj1);
|
||||
Assertions.assertNotSame(obj, obj1); |
// Assertions.assertNotSame(obj, obj1);
|
||||
} |
// }
|
||||
|
//
|
||||
@DisplayName("测试 assertTrue 方法") |
// @DisplayName("测试 assertTrue 方法")
|
||||
@Test |
// @Test
|
||||
public void testAssertTrue() { |
// public void testAssertTrue() {
|
||||
Assertions.assertTrue(true); |
// Assertions.assertTrue(true);
|
||||
Assertions.assertFalse(true); |
// Assertions.assertFalse(true);
|
||||
} |
// }
|
||||
|
//
|
||||
@DisplayName("测试 assertNull 方法") |
// @DisplayName("测试 assertNull 方法")
|
||||
@Test |
// @Test
|
||||
public void testAssertNull() { |
// public void testAssertNull() {
|
||||
Assertions.assertNull(null); |
// Assertions.assertNull(null);
|
||||
Assertions.assertNotNull(null); |
// Assertions.assertNotNull(null);
|
||||
} |
// }
|
||||
|
//
|
||||
} |
//}
|
||||
|
@ -1,70 +1,70 @@ |
|||||
package org.dromara.test; |
//package org.dromara.test;
|
||||
|
//
|
||||
import org.dromara.common.core.config.RuoYiConfig; |
//import org.dromara.common.core.config.RuoYiConfig;
|
||||
import org.junit.jupiter.api.*; |
//import org.junit.jupiter.api.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest; |
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
//
|
||||
import java.util.concurrent.TimeUnit; |
//import java.util.concurrent.TimeUnit;
|
||||
|
//
|
||||
/** |
///**
|
||||
* 单元测试案例 |
// * 单元测试案例
|
||||
* |
// *
|
||||
* @author Lion Li |
// * @author Lion Li
|
||||
*/ |
// */
|
||||
@SpringBootTest // 此注解只能在 springboot 主包下使用 需包含 main 方法与 yml 配置文件
|
//@SpringBootTest // 此注解只能在 springboot 主包下使用 需包含 main 方法与 yml 配置文件
|
||||
@DisplayName("单元测试案例") |
//@DisplayName("单元测试案例")
|
||||
public class DemoUnitTest { |
//public class DemoUnitTest {
|
||||
|
//
|
||||
@Autowired |
// @Autowired
|
||||
private RuoYiConfig ruoYiConfig; |
// private RuoYiConfig ruoYiConfig;
|
||||
|
//
|
||||
@DisplayName("测试 @SpringBootTest @Test @DisplayName 注解") |
// @DisplayName("测试 @SpringBootTest @Test @DisplayName 注解")
|
||||
@Test |
// @Test
|
||||
public void testTest() { |
// public void testTest() {
|
||||
System.out.println(ruoYiConfig); |
// System.out.println(ruoYiConfig);
|
||||
} |
// }
|
||||
|
//
|
||||
@Disabled |
// @Disabled
|
||||
@DisplayName("测试 @Disabled 注解") |
// @DisplayName("测试 @Disabled 注解")
|
||||
@Test |
// @Test
|
||||
public void testDisabled() { |
// public void testDisabled() {
|
||||
System.out.println(ruoYiConfig); |
// System.out.println(ruoYiConfig);
|
||||
} |
// }
|
||||
|
//
|
||||
@Timeout(value = 2L, unit = TimeUnit.SECONDS) |
// @Timeout(value = 2L, unit = TimeUnit.SECONDS)
|
||||
@DisplayName("测试 @Timeout 注解") |
// @DisplayName("测试 @Timeout 注解")
|
||||
@Test |
// @Test
|
||||
public void testTimeout() throws InterruptedException { |
// public void testTimeout() throws InterruptedException {
|
||||
Thread.sleep(3000); |
// Thread.sleep(3000);
|
||||
System.out.println(ruoYiConfig); |
// System.out.println(ruoYiConfig);
|
||||
} |
// }
|
||||
|
//
|
||||
|
//
|
||||
@DisplayName("测试 @RepeatedTest 注解") |
// @DisplayName("测试 @RepeatedTest 注解")
|
||||
@RepeatedTest(3) |
// @RepeatedTest(3)
|
||||
public void testRepeatedTest() { |
// public void testRepeatedTest() {
|
||||
System.out.println(666); |
// System.out.println(666);
|
||||
} |
// }
|
||||
|
//
|
||||
@BeforeAll |
// @BeforeAll
|
||||
public static void testBeforeAll() { |
// public static void testBeforeAll() {
|
||||
System.out.println("@BeforeAll =================="); |
// System.out.println("@BeforeAll ==================");
|
||||
} |
// }
|
||||
|
//
|
||||
@BeforeEach |
// @BeforeEach
|
||||
public void testBeforeEach() { |
// public void testBeforeEach() {
|
||||
System.out.println("@BeforeEach =================="); |
// System.out.println("@BeforeEach ==================");
|
||||
} |
// }
|
||||
|
//
|
||||
@AfterEach |
// @AfterEach
|
||||
public void testAfterEach() { |
// public void testAfterEach() {
|
||||
System.out.println("@AfterEach =================="); |
// System.out.println("@AfterEach ==================");
|
||||
} |
// }
|
||||
|
//
|
||||
@AfterAll |
// @AfterAll
|
||||
public static void testAfterAll() { |
// public static void testAfterAll() {
|
||||
System.out.println("@AfterAll =================="); |
// System.out.println("@AfterAll ==================");
|
||||
} |
// }
|
||||
|
//
|
||||
} |
//}
|
||||
|
@ -1,72 +1,72 @@ |
|||||
package org.dromara.test; |
//package org.dromara.test;
|
||||
|
//
|
||||
import org.dromara.common.core.enums.UserType; |
//import org.dromara.common.core.enums.UserType;
|
||||
import org.junit.jupiter.api.AfterEach; |
//import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach; |
//import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName; |
//import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.params.ParameterizedTest; |
//import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource; |
//import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.junit.jupiter.params.provider.MethodSource; |
//import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.NullSource; |
//import org.junit.jupiter.params.provider.NullSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource; |
//import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
//
|
||||
import java.util.ArrayList; |
//import java.util.ArrayList;
|
||||
import java.util.List; |
//import java.util.List;
|
||||
import java.util.stream.Stream; |
//import java.util.stream.Stream;
|
||||
|
//
|
||||
/** |
///**
|
||||
* 带参数单元测试案例 |
// * 带参数单元测试案例
|
||||
* |
// *
|
||||
* @author Lion Li |
// * @author Lion Li
|
||||
*/ |
// */
|
||||
@DisplayName("带参数单元测试案例") |
//@DisplayName("带参数单元测试案例")
|
||||
public class ParamUnitTest { |
//public class ParamUnitTest {
|
||||
|
//
|
||||
@DisplayName("测试 @ValueSource 注解") |
// @DisplayName("测试 @ValueSource 注解")
|
||||
@ParameterizedTest |
// @ParameterizedTest
|
||||
@ValueSource(strings = {"t1", "t2", "t3"}) |
// @ValueSource(strings = {"t1", "t2", "t3"})
|
||||
public void testValueSource(String str) { |
// public void testValueSource(String str) {
|
||||
System.out.println(str); |
// System.out.println(str);
|
||||
} |
// }
|
||||
|
//
|
||||
@DisplayName("测试 @NullSource 注解") |
// @DisplayName("测试 @NullSource 注解")
|
||||
@ParameterizedTest |
// @ParameterizedTest
|
||||
@NullSource |
// @NullSource
|
||||
public void testNullSource(String str) { |
// public void testNullSource(String str) {
|
||||
System.out.println(str); |
// System.out.println(str);
|
||||
} |
// }
|
||||
|
//
|
||||
@DisplayName("测试 @EnumSource 注解") |
// @DisplayName("测试 @EnumSource 注解")
|
||||
@ParameterizedTest |
// @ParameterizedTest
|
||||
@EnumSource(UserType.class) |
// @EnumSource(UserType.class)
|
||||
public void testEnumSource(UserType type) { |
// public void testEnumSource(UserType type) {
|
||||
System.out.println(type.getUserType()); |
// System.out.println(type.getUserType());
|
||||
} |
// }
|
||||
|
//
|
||||
@DisplayName("测试 @MethodSource 注解") |
// @DisplayName("测试 @MethodSource 注解")
|
||||
@ParameterizedTest |
// @ParameterizedTest
|
||||
@MethodSource("getParam") |
// @MethodSource("getParam")
|
||||
public void testMethodSource(String str) { |
// public void testMethodSource(String str) {
|
||||
System.out.println(str); |
// System.out.println(str);
|
||||
} |
// }
|
||||
|
//
|
||||
public static Stream<String> getParam() { |
// public static Stream<String> getParam() {
|
||||
List<String> list = new ArrayList<>(); |
// List<String> list = new ArrayList<>();
|
||||
list.add("t1"); |
// list.add("t1");
|
||||
list.add("t2"); |
// list.add("t2");
|
||||
list.add("t3"); |
// list.add("t3");
|
||||
return list.stream(); |
// return list.stream();
|
||||
} |
// }
|
||||
|
//
|
||||
@BeforeEach |
// @BeforeEach
|
||||
public void testBeforeEach() { |
// public void testBeforeEach() {
|
||||
System.out.println("@BeforeEach =================="); |
// System.out.println("@BeforeEach ==================");
|
||||
} |
// }
|
||||
|
//
|
||||
@AfterEach |
// @AfterEach
|
||||
public void testAfterEach() { |
// public void testAfterEach() {
|
||||
System.out.println("@AfterEach =================="); |
// System.out.println("@AfterEach ==================");
|
||||
} |
// }
|
||||
|
//
|
||||
|
//
|
||||
} |
//}
|
||||
|
@ -1,54 +1,54 @@ |
|||||
package org.dromara.test; |
//package org.dromara.test;
|
||||
|
//
|
||||
import org.junit.jupiter.api.*; |
//import org.junit.jupiter.api.*;
|
||||
import org.springframework.boot.test.context.SpringBootTest; |
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
//
|
||||
/** |
///**
|
||||
* 标签单元测试案例 |
// * 标签单元测试案例
|
||||
* |
// *
|
||||
* @author Lion Li |
// * @author Lion Li
|
||||
*/ |
// */
|
||||
@SpringBootTest |
//@SpringBootTest
|
||||
@DisplayName("标签单元测试案例") |
//@DisplayName("标签单元测试案例")
|
||||
public class TagUnitTest { |
//public class TagUnitTest {
|
||||
|
//
|
||||
@Tag("dev") |
// @Tag("dev")
|
||||
@DisplayName("测试 @Tag dev") |
// @DisplayName("测试 @Tag dev")
|
||||
@Test |
// @Test
|
||||
public void testTagDev() { |
// public void testTagDev() {
|
||||
System.out.println("dev"); |
// System.out.println("dev");
|
||||
} |
// }
|
||||
|
//
|
||||
@Tag("prod") |
// @Tag("prod")
|
||||
@DisplayName("测试 @Tag prod") |
// @DisplayName("测试 @Tag prod")
|
||||
@Test |
// @Test
|
||||
public void testTagProd() { |
// public void testTagProd() {
|
||||
System.out.println("prod"); |
// System.out.println("prod");
|
||||
} |
// }
|
||||
|
//
|
||||
@Tag("local") |
// @Tag("local")
|
||||
@DisplayName("测试 @Tag local") |
// @DisplayName("测试 @Tag local")
|
||||
@Test |
// @Test
|
||||
public void testTagLocal() { |
// public void testTagLocal() {
|
||||
System.out.println("local"); |
// System.out.println("local");
|
||||
} |
// }
|
||||
|
//
|
||||
@Tag("exclude") |
// @Tag("exclude")
|
||||
@DisplayName("测试 @Tag exclude") |
// @DisplayName("测试 @Tag exclude")
|
||||
@Test |
// @Test
|
||||
public void testTagExclude() { |
// public void testTagExclude() {
|
||||
System.out.println("exclude"); |
// System.out.println("exclude");
|
||||
} |
// }
|
||||
|
//
|
||||
@BeforeEach |
// @BeforeEach
|
||||
public void testBeforeEach() { |
// public void testBeforeEach() {
|
||||
System.out.println("@BeforeEach =================="); |
// System.out.println("@BeforeEach ==================");
|
||||
} |
// }
|
||||
|
//
|
||||
@AfterEach |
// @AfterEach
|
||||
public void testAfterEach() { |
// public void testAfterEach() {
|
||||
System.out.println("@AfterEach =================="); |
// System.out.println("@AfterEach ==================");
|
||||
} |
// }
|
||||
|
//
|
||||
|
//
|
||||
} |
//}
|
||||
|
@ -0,0 +1,15 @@ |
|||||
|
package org.dromara.demo.domain.vo; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
public class AllGoatAchieve { |
||||
|
private String date; |
||||
|
private String planInvest; |
||||
|
private String actualInvest; |
||||
|
private String investPercent; |
||||
|
} |
Loading…
Reference in new issue