Skip to content

Commit dc1b92e

Browse files
migrate 52 to junit 5
1 parent 643827c commit dc1b92e

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

Diff for: src/test/java/com/fishercoder/_51Test.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.fishercoder;
22

33
import com.fishercoder.solutions._51;
4-
import org.junit.Test;
54
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
66

77
import java.util.ArrayList;
88
import java.util.Arrays;

Diff for: src/test/java/com/fishercoder/_52Test.java

+24-31
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
11
package com.fishercoder;
22

33
import com.fishercoder.solutions._52;
4-
import org.junit.Before;
5-
import org.junit.BeforeClass;
6-
import org.junit.Test;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
76

8-
import static junit.framework.Assert.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
98

109
public class _52Test {
11-
private static _52.Solution1 solution1;
12-
13-
@BeforeClass
14-
public static void setup() {
15-
solution1 = new _52.Solution1();
16-
}
17-
18-
@Before
19-
public void clear() {
20-
/**Solution1 has an instance variable `count`, so I'll have to create a new one for each test*/
21-
solution1 = new _52.Solution1();
22-
}
23-
24-
@Test
25-
public void test1() {
26-
assertEquals(1, solution1.totalNQueens(1));
27-
}
28-
29-
@Test
30-
public void test2() {
31-
assertEquals(92, solution1.totalNQueens(8));
32-
}
33-
34-
@Test
35-
public void test3() {
36-
assertEquals(0, solution1.totalNQueens(2));
37-
}
10+
private static _52.Solution1 solution1;
11+
12+
@BeforeEach
13+
public void setup() {
14+
solution1 = new _52.Solution1();
15+
}
16+
17+
@Test
18+
public void test1() {
19+
assertEquals(1, solution1.totalNQueens(1));
20+
}
21+
22+
@Test
23+
public void test2() {
24+
assertEquals(92, solution1.totalNQueens(8));
25+
}
26+
27+
@Test
28+
public void test3() {
29+
assertEquals(0, solution1.totalNQueens(2));
30+
}
3831
}

0 commit comments

Comments
 (0)