统计订单总金额

This commit is contained in:
2025-08-04 07:09:01 +08:00
parent 7883a7291f
commit fe03c3cd01
9 changed files with 537 additions and 1 deletions

View 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秒以内");
}
}

View 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秒以内");
}
}