Skip to content

Commit 423cd96

Browse files
committed
Add junit testing starting project
1 parent 0d96aab commit 423cd96

3 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.luv2code</groupId>
8+
<artifactId>junitdemo</artifactId>
9+
<version>1.0</version>
10+
11+
<properties>
12+
<maven.compiler.source>23</maven.compiler.source>
13+
<maven.compiler.target>23</maven.compiler.target>
14+
</properties>
15+
16+
</project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.luv2code.junitdemo;
2+
3+
import java.util.List;
4+
5+
public class DemoUtils {
6+
7+
private String academy = "Luv2Code Academy";
8+
private String academyDuplicate = academy;
9+
private String[] firstThreeLettersOfAlphabet = {"A", "B", "C"};
10+
private List<String> academyInList = List.of("luv", "2", "code");
11+
12+
public List<String> getAcademyInList() {
13+
return academyInList;
14+
}
15+
16+
public String getAcademy() {
17+
return academy;
18+
}
19+
20+
public String getAcademyDuplicate() {
21+
return academyDuplicate;
22+
}
23+
24+
public String[] getFirstThreeLettersOfAlphabet() {
25+
return firstThreeLettersOfAlphabet;
26+
}
27+
28+
public int add(int a, int b) {
29+
return a + b;
30+
}
31+
32+
public int multiply(int a, int b) {
33+
return a * b;
34+
}
35+
36+
public Object checkNull(Object obj) {
37+
if (obj != null) {
38+
return obj;
39+
}
40+
return null;
41+
}
42+
43+
public Boolean isGreater(int n1, int n2) {
44+
if (n1 > n2) {
45+
return true;
46+
}
47+
return false;
48+
}
49+
50+
public String throwException(int a) throws Exception {
51+
if (a < 0) {
52+
throw new Exception("Value should be greater than or equal to 0");
53+
}
54+
return "Value is greater than or equal to 0";
55+
}
56+
57+
public void checkTimeout() throws InterruptedException {
58+
System.out.println("I am going to sleep");
59+
Thread.sleep(2000);
60+
System.out.println("Sleeping over");
61+
}
62+
63+
}

section-10-unit-testing-quick-start/00-starting-project/src/test/java/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)