File tree Expand file tree Collapse file tree
main/java/com/wdbyte/junit5
test/java/com/wdbyte/junit5 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /target /
2+ * /systemlog /
3+ ! .mvn /wrapper /maven-wrapper.jar
4+
5+ # ## STS ###
6+ .apt_generated
7+ .classpath
8+ .factorypath
9+ .project
10+ .settings
11+ .springBeans
12+ .sts4-cache
13+
14+ # ## IntelliJ IDEA ###
15+ .idea
16+ * .iws
17+ * .iml
18+ * .ipr
19+
20+ # ## NetBeans ###
21+ /nbproject /private /
22+ /build /
23+ /nbbuild /
24+ /dist /
25+ /nbdist /
26+ /.nb-gradle /%
Original file line number Diff line number Diff line change 1+ package com .wdbyte .junit5 ;
2+
3+ import java .net .InetAddress ;
4+ import java .net .UnknownHostException ;
5+ import java .nio .charset .Charset ;
6+
7+ /**
8+ * @author niulang
9+ * @date 2022/03/16
10+ */
11+ public class Calculator {
12+
13+ public int add (int x , int y ) {
14+ return x + y ;
15+ }
16+ public static void main (String [] args ) throws UnknownHostException {
17+ InetAddress byName = InetAddress .getByName ("www.baidu.com" );
18+ System .out .println (byName .getHostAddress ());
19+ //Java使用的默认字符集
20+ System .out .println ("java 默认字符集:" );
21+ System .out .println (Charset .defaultCharset ()+"\n " );
22+ //汉字“测”的字节编码
23+ String str = "测试一下" ;
24+ //这里可以手动设置编码字符集,默认使用utf-8编码
25+ byte [] bytes = str .getBytes ();
26+ System .out .println ("汉字\" 测\" 的编码:" );
27+ for (byte bt : bytes ){
28+ System .out .println (bt );
29+ }
30+
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ package com .wdbyte .junit5 ;
2+
3+ import org .junit .jupiter .api .DisplayName ;
4+ import org .junit .jupiter .api .RepeatedTest ;
5+ import org .junit .jupiter .api .Tag ;
6+ import org .junit .jupiter .api .Test ;
7+ import org .junit .jupiter .params .ParameterizedTest ;
8+ import org .junit .jupiter .params .provider .ValueSource ;
9+
10+ import static org .junit .jupiter .api .Assertions .*;
11+
12+ /**
13+ * @author niulang
14+ * @date 2022/03/16
15+ */
16+ @ DisplayName ("计算器" )
17+ class CalculatorTest {
18+
19+ private final Calculator calculator = new Calculator ();
20+
21+ //@Tag("fast")
22+ @ Test
23+ //@RepeatedTest(2)
24+ @ DisplayName ("相加" )
25+ //@ParameterizedTest()
26+ //@ValueSource(ints = { -1, -4 })
27+ void add () {
28+ assertEquals (3 , calculator .add (1 , 1 ));
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments