统计订单总金额
This commit is contained in:
56
src/test/java/com/gxwebsoft/bszx/BszxOrderTotalTest.java
Normal file
56
src/test/java/com/gxwebsoft/bszx/BszxOrderTotalTest.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.gxwebsoft.bszx;
|
||||
|
||||
import com.gxwebsoft.bszx.service.BszxPayService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* 百色中学订单总金额统计测试
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-07-31
|
||||
*/
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("test")
|
||||
public class BszxOrderTotalTest {
|
||||
|
||||
@Resource
|
||||
private BszxPayService bszxPayService;
|
||||
|
||||
@Test
|
||||
void testBszxOrderTotal() {
|
||||
// 测试百色中学订单总金额统计
|
||||
BigDecimal total = bszxPayService.total();
|
||||
|
||||
// 验证返回值不为null
|
||||
assertNotNull(total, "百色中学订单总金额不应该为null");
|
||||
|
||||
// 验证返回值大于等于0
|
||||
assertTrue(total.compareTo(BigDecimal.ZERO) >= 0, "百色中学订单总金额应该大于等于0");
|
||||
|
||||
System.out.println("百色中学订单总金额统计结果:" + total);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBszxOrderTotalPerformance() {
|
||||
// 测试性能
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
BigDecimal total = bszxPayService.total();
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
long duration = endTime - startTime;
|
||||
|
||||
System.out.println("百色中学订单总金额统计耗时:" + duration + "ms");
|
||||
System.out.println("统计结果:" + total);
|
||||
|
||||
// 验证查询时间在合理范围内(小于5秒)
|
||||
assertTrue(duration < 5000, "查询时间应该在5秒以内");
|
||||
}
|
||||
}
|
||||
56
src/test/java/com/gxwebsoft/shop/OrderTotalTest.java
Normal file
56
src/test/java/com/gxwebsoft/shop/OrderTotalTest.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.gxwebsoft.shop;
|
||||
|
||||
import com.gxwebsoft.shop.service.ShopOrderService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* 订单总金额统计测试
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-07-30
|
||||
*/
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("test")
|
||||
public class OrderTotalTest {
|
||||
|
||||
@Resource
|
||||
private ShopOrderService shopOrderService;
|
||||
|
||||
@Test
|
||||
void testOrderTotal() {
|
||||
// 测试订单总金额统计
|
||||
BigDecimal total = shopOrderService.total();
|
||||
|
||||
// 验证返回值不为null
|
||||
assertNotNull(total, "订单总金额不应该为null");
|
||||
|
||||
// 验证返回值大于等于0
|
||||
assertTrue(total.compareTo(BigDecimal.ZERO) >= 0, "订单总金额应该大于等于0");
|
||||
|
||||
System.out.println("订单总金额统计结果:" + total);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOrderTotalPerformance() {
|
||||
// 测试性能
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
BigDecimal total = shopOrderService.total();
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
long duration = endTime - startTime;
|
||||
|
||||
System.out.println("订单总金额统计耗时:" + duration + "ms");
|
||||
System.out.println("统计结果:" + total);
|
||||
|
||||
// 验证查询时间在合理范围内(小于5秒)
|
||||
assertTrue(duration < 5000, "查询时间应该在5秒以内");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user