Skip to content

Commit 860f98f

Browse files
committed
Stop using assertTrue(false)
This is plain wrong as it will always fail. Use fail directly or simplify tests where possible to remove the need for it. Other small improvements to tests done wherever seen while doing the main changes here.
1 parent 2c59dfb commit 860f98f

File tree

10 files changed

+412
-690
lines changed

10 files changed

+412
-690
lines changed

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2016 IBM Corporation and others.
2+
* Copyright (c) 2006, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -16,6 +16,7 @@
1616

1717
import static org.junit.Assert.assertEquals;
1818
import static org.junit.Assert.assertTrue;
19+
import static org.junit.Assert.fail;
1920

2021
import java.io.IOException;
2122
import java.io.Reader;
@@ -76,7 +77,7 @@ private void verify(String input, String expectedOutput, int styleRangeCount) th
7677
StyleRange range2= ranges.get(i + 1);
7778

7879
if (range1.start + range1.length > range2.start) {
79-
assertTrue("StyleRanges overlap", false);
80+
fail("StyleRanges overlap");
8081
}
8182
}
8283

@@ -108,7 +109,7 @@ private void verify(String input, String expectedOutput, StyleRange[] styleRange
108109
StyleRange range2= ranges.get(i + 1);
109110

110111
if (range1.start + range1.length > range2.start) {
111-
assertTrue("StyleRanges overlap", false);
112+
fail("StyleRanges overlap");
112113
}
113114
}
114115

tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2015 IBM Corporation and others.
2+
* Copyright (c) 2007, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,7 +13,7 @@
1313
*******************************************************************************/
1414
package org.eclipse.text.tests;
1515

16-
import static org.junit.Assert.assertTrue;
16+
import static org.junit.Assert.fail;
1717

1818
import java.util.ArrayList;
1919
import java.util.Arrays;
@@ -139,7 +139,7 @@ private void assertEquals(Annotation[] expected, Annotation[] actual, IAnnotatio
139139
for (Annotation a : actual) {
140140
if (!expectedSet.contains(a)) {
141141
String message = "Unexpected annotation " + getName(a) + " in result with models [" + getAnnotationModelNames(insideModel, beforeModel, afterModel) + "]";
142-
assertTrue(message, false);
142+
fail(message);
143143
}
144144
expectedSet.remove(a);
145145
}
@@ -149,7 +149,7 @@ private void assertEquals(Annotation[] expected, Annotation[] actual, IAnnotatio
149149
for (Annotation missing : expectedSet) {
150150
message= message + "\n" + getName(missing);
151151
}
152-
assertTrue(message, false);
152+
fail(message);
153153
}
154154
}
155155

0 commit comments

Comments
 (0)