Junit 多组测试数据测试
发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,使用 Junit 指定多组测试数据进行测试。测试方法使用的 SHA3Utils 代码仓库地址: java-coreParameterized 测试批量指定多个待测参数, 按数据逐一测试import o
千家信息网最后更新 2026年11月01日Junit 多组测试数据测试
使用 Junit 指定多组测试数据进行测试。
测试方法使用的 SHA3Utils 代码仓库地址: java-core
Parameterized 测试
批量指定多个待测参数, 按数据逐一测试
import org.junit.Test;import org.junit.runner.RunWith;import org.junit.runners.Parameterized;import java.util.Arrays;import java.util.List;/** * Description: JunitTest 批量指定多个待测参数, 按数据逐一测试 * Blog: http://blog.wxcsdb88.com
* * @author wxcsdb88 * @since 2017-12-10 00:21 **/@RunWith(Parameterized.class)public class JunitTestParameterizeDemo { private String input; public JunitTestParameterizeDemo(String input) { this.input = input; } @Parameterized.Parameters public static List getParams() { return Arrays.asList("hello", "hi", "good morning", "how are you"); } @Test public void sha224() throws Exception { String result = SHA3Utils.sha224(input); System.out.println(String.format("input is %s, SHA3-224 output: %s", input, result)); } @Test public void sha256() throws Exception { String result = SHA3Utils.sha256(input); System.out.println(String.format("input is %s, SHA3-256 output: %s", input, result)); } @Test public void sha384() throws Exception { String result = SHA3Utils.sha384(input); System.out.println(String.format("input is %s, SHA3-384 output: %s", input, result)); } @Test public void sha512() throws Exception { String result = SHA3Utils.sha512(input); System.out.println(String.format("input is %s, SHA3-512 output: %s", input, result)); }}Theories 测试
提供一组参数的排列组合值作为待测试方法的输入参数, 按照方法逐一测试
import org.junit.experimental.theories.DataPoints;import org.junit.experimental.theories.Theories;import org.junit.experimental.theories.Theory;import org.junit.runner.RunWith;/** * Description: theories 提供一组参数的排列组合值作为待测试方法的输入参数, 按照方法逐一测试 * Blog: http://blog.wxcsdb88.com
* * @author wxcsdb88 * @since 2017-12-10 00:21 **/@RunWith(Theories.class)public class JUnitTestDemoTheories { @DataPoints public static String[] inputs = {"hello", "hi", "good morning", "how are you"}; @Theory public void sha224Theories(String input) throws Exception { String result = SHA3Utils.sha224(input); System.out.println(String.format("input is %s, SHA3-224 output: %s", input, result)); } @Theory public void sha256(String input) throws Exception { String result = SHA3Utils.sha256(input); System.out.println(String.format("input is %s, SHA3-256 output: %s", input, result)); } @Theory public void sha384(String input) throws Exception { String result = SHA3Utils.sha384(input); System.out.println(String.format("input is %s, SHA3-384 output: %s", input, result)); } @Theory public void sha512(String input) throws Exception { String result = SHA3Utils.sha512(input); System.out.println(String.format("input is %s, SHA3-512 output: %s", input, result)); }}
测试
参数
方法
数据
多个
组合
输入
仓库
代码
地址
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
广州淘业互联网络科技
互联网科技网
深圳恒合互联网络科技有限公司
互联网是不是新科技
鸠鸠互联网科技
互联网与科技金融数据
润盈互联网科技
互联网科技公司名称
科技大学互联网专业好不好
济南和联互联网科技有限公司
互联网时代科技改变生活
科技赋能视角下互联网保险发展
恒生互联网科技业指数调整周期
山东星卡互联网科技有限公司官网
上海钢联属于互联网科技股吗
互联网安防科技感
珠海东科互联网科技有限公司
云鲸互联网络科技有限公司
10位科技互联网大佬
知域互联网科技有限公司官网
华服互联网科技怎么样
互联网科技论坛
互联网 新科技
互联网和高科技公司
央行互联网金融科技公司
畅思互联网科技
合肥互联网科技公司公章图片
易租星互联网科技有限公司
科技互联网经济论坛
互联网科技创业有什么好项目