Skip to content

Commit 273ab31

Browse files
committed
Switch to JUnit4 for "tests"
1 parent ae33518 commit 273ab31

131 files changed

Lines changed: 737 additions & 713 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/src/test/java/org/mozilla/classfile/tests/ClassFileWriterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package org.mozilla.classfile.tests;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.jupiter.api.Assertions.*;
44
import static org.mozilla.classfile.ClassFileWriter.ACC_PUBLIC;
55
import static org.mozilla.classfile.ClassFileWriter.ACC_STATIC;
66

77
import java.lang.reflect.Method;
88
import java.math.BigInteger;
9-
import org.junit.Test;
9+
import org.junit.jupiter.api.Test;
1010
import org.mozilla.classfile.ByteCode;
1111
import org.mozilla.classfile.ClassFileWriter;
1212
import org.mozilla.javascript.DefiningClassLoader;

tests/src/test/java/org/mozilla/javascript/drivers/JsTestsBase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
package org.mozilla.javascript.drivers;
66

7-
import static org.junit.Assert.assertTrue;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
88

99
import java.io.File;
1010
import java.io.FileReader;
1111
import java.io.IOException;
12-
import org.junit.BeforeClass;
12+
import org.junit.jupiter.api.BeforeAll;
1313
import org.mozilla.javascript.Context;
1414
import org.mozilla.javascript.ContextFactory;
1515
import org.mozilla.javascript.Scriptable;
@@ -21,7 +21,7 @@ public abstract class JsTestsBase {
2121

2222
private static ContextFactory threadSafeFactory;
2323

24-
@BeforeClass
24+
@BeforeAll
2525
public static void init() {
2626
threadSafeFactory = Utils.contextFactoryWithFeatures(Context.FEATURE_THREAD_SAFE_OBJECTS);
2727
}

tests/src/test/java/org/mozilla/javascript/drivers/ScriptTestsBase.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44

55
package org.mozilla.javascript.drivers;
66

7-
import static org.junit.Assert.assertEquals;
8-
import static org.junit.Assert.assertNotNull;
9-
import static org.junit.Assert.fail;
7+
import static org.junit.jupiter.api.Assertions.*;
108

119
import java.io.FileInputStream;
1210
import java.io.IOException;
1311
import java.io.InputStreamReader;
1412
import java.io.Reader;
1513
import java.io.StringReader;
1614
import java.nio.charset.StandardCharsets;
17-
import org.junit.Test;
18-
import org.junit.runner.RunWith;
19-
import org.junit.runners.BlockJUnit4ClassRunner;
15+
import org.junit.jupiter.api.Test;
2016
import org.mozilla.javascript.Callable;
2117
import org.mozilla.javascript.Context;
2218
import org.mozilla.javascript.JavaScriptException;
@@ -33,7 +29,6 @@
3329
* represented by a class that extends this class, and has a "RhinoTest" annotation at the class
3430
* level that returns the file name of the script to execute.
3531
*/
36-
@RunWith(BlockJUnit4ClassRunner.class)
3732
public abstract class ScriptTestsBase {
3833

3934
private Object executeRhinoScript(boolean interpretedMode) {

tests/src/test/java/org/mozilla/javascript/testing/TestErrorReporter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
package org.mozilla.javascript.testing;
66

7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.fail;
9+
710
import org.junit.Assert;
811
import org.mozilla.javascript.ErrorReporter;
912
import org.mozilla.javascript.EvaluatorException;

tests/src/test/java/org/mozilla/javascript/tests/ApplyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.mozilla.javascript.tests;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44
import org.mozilla.javascript.testutils.Utils;
55

66
public class ApplyTest {

tests/src/test/java/org/mozilla/javascript/tests/BracelessIfElseWithCommentsParseTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import java.io.FileReader;
55
import java.io.IOException;
66
import java.util.stream.Collectors;
7-
import org.junit.Assert;
8-
import org.junit.Test;
7+
import org.junit.jupiter.api.Assertions;
8+
import org.junit.jupiter.api.Test;
99
import org.mozilla.javascript.CompilerEnvirons;
1010
import org.mozilla.javascript.Parser;
1111
import org.mozilla.javascript.ast.AstRoot;
@@ -35,10 +35,10 @@ public void testBracelessIfElseWithMultipleComments() throws IOException {
3535

3636
// Parsing should not throw a syntax error
3737
AstRoot ast = parser.parse(source, "test", 1);
38-
Assert.assertNotNull(ast);
38+
Assertions.assertNotNull(ast);
3939

4040
// The fixture has 18 comments — verify they were all recorded
41-
Assert.assertEquals(14, ast.getComments().size());
41+
Assertions.assertEquals(14, ast.getComments().size());
4242
}
4343

4444
@Test
@@ -56,8 +56,8 @@ public void testMinimalTwoCommentRepro() {
5656

5757
Parser parser = new Parser(env);
5858
AstRoot ast = parser.parse(source, "test", 1);
59-
Assert.assertNotNull(ast);
60-
Assert.assertEquals(1, ast.getComments().size());
59+
Assertions.assertNotNull(ast);
60+
Assertions.assertEquals(1, ast.getComments().size());
6161
}
6262

6363
@Test
@@ -74,8 +74,8 @@ public void testSingleCommentStillWorks() {
7474

7575
Parser parser = new Parser(env);
7676
AstRoot ast = parser.parse(source, "test", 1);
77-
Assert.assertNotNull(ast);
78-
Assert.assertEquals(1, ast.getComments().size());
77+
Assertions.assertNotNull(ast);
78+
Assertions.assertEquals(1, ast.getComments().size());
7979
}
8080

8181
@Test
@@ -100,7 +100,7 @@ public void testConsecutiveCommentsAreMergedInToSource() {
100100
+ " doSomething();\n"
101101
+ "else \n"
102102
+ " doSomethingElse();\n";
103-
Assert.assertEquals(expected, ast.toSource());
103+
Assertions.assertEquals(expected, ast.toSource());
104104
}
105105

106106
@Test
@@ -116,12 +116,12 @@ public void testCommentContentAfterMerging() {
116116

117117
// Check how many comments are in the global list
118118
java.util.SortedSet<org.mozilla.javascript.ast.Comment> comments = ast.getComments();
119-
Assert.assertEquals(1, comments.size());
119+
Assertions.assertEquals(1, comments.size());
120120

121121
java.util.Iterator<org.mozilla.javascript.ast.Comment> it = comments.iterator();
122122
org.mozilla.javascript.ast.Comment c1 = it.next();
123123

124-
Assert.assertEquals("// comment 1\n// comment 2", c1.getValue());
124+
Assertions.assertEquals("// comment 1\n// comment 2", c1.getValue());
125125
}
126126

127127
@Test
@@ -139,6 +139,6 @@ public void testWithoutRecordingCommentsStillWorks() {
139139

140140
Parser parser = new Parser(env);
141141
AstRoot ast = parser.parse(source, "test", 1);
142-
Assert.assertNotNull(ast);
142+
Assertions.assertNotNull(ast);
143143
}
144144
}

tests/src/test/java/org/mozilla/javascript/tests/BuiltinCtorTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.mozilla.javascript.tests;
22

3-
import static org.junit.Assert.assertNotNull;
4-
import static org.junit.Assert.assertTrue;
3+
import static org.junit.jupiter.api.Assertions.assertNotNull;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
55

6-
import org.junit.Test;
6+
import org.junit.jupiter.api.Test;
77
import org.mozilla.javascript.Context;
88
import org.mozilla.javascript.Scriptable;
99
import org.mozilla.javascript.TopLevel;
@@ -29,11 +29,11 @@ public void checkCtorArity() {
2929
continue;
3030
}
3131
assertTrue(
32-
String.format("Expected %s() to return an object", bi.name()),
33-
res instanceof Scriptable);
32+
res instanceof Scriptable,
33+
String.format("Expected %s() to return an object", bi.name()));
3434
assertNotNull(
35-
String.format("Expected %s() to set parent scope", bi.name()),
36-
((Scriptable) res).getParentScope());
35+
((Scriptable) res).getParentScope(),
36+
String.format("Expected %s() to set parent scope", bi.name()));
3737
}
3838
}
3939
}

tests/src/test/java/org/mozilla/javascript/tests/CharacterAssignmentTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

5-
import org.junit.Test;
5+
import org.junit.jupiter.api.Test;
66
import org.mozilla.javascript.testutils.Utils;
77
import org.mozilla.javascript.tools.shell.Global;
88

tests/src/test/java/org/mozilla/javascript/tests/ComparatorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package org.mozilla.javascript.tests;
22

3-
import static org.junit.Assert.assertEquals;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.mozilla.javascript.ArrayLikeAbstractOperations.*;
55

66
import java.io.FileReader;
77
import java.io.IOException;
8-
import org.junit.Test;
8+
import org.junit.jupiter.api.Test;
99
import org.mozilla.javascript.Context;
1010
import org.mozilla.javascript.RhinoException;
1111
import org.mozilla.javascript.Scriptable;

tests/src/test/java/org/mozilla/javascript/tests/ComputedPropertiesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
package org.mozilla.javascript.tests;
66

7-
import org.junit.Test;
7+
import org.junit.jupiter.api.Test;
88
import org.mozilla.javascript.testutils.Utils;
99

1010
public class ComputedPropertiesTest {

0 commit comments

Comments
 (0)