Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Junit multi-group test data test

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Use Junit to specify multiple sets of test data for testing.

SHA3Utils code repository used by the test method address: java-core

Parameterized test

Specify multiple parameters to be tested in batches and test them one by one according to the data

Import org.junit.Test;import org.junit.runner.RunWith;import org.junit.runners.Parameterized;import java.util.Arrays;import java.util.List;/** * Description: JunitTest specifies multiple parameters to be tested in batches, and tests them one by one according to the data *

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-256output:% 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 Test

Provide the permutation and combination values of a set of parameters as the input parameters of the method to be tested, and test them one by one according to the method.

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 provides the permutation and combination values of a set of parameters as the input parameters of the method to be tested, and tests them one by one according to the method *

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);}}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report