-
Type:
Enhancement
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: None
-
Component/s: core-libs
-
b09
ModuleReaderTest is full of "bare" assertions which don't provide context and obfuscate any work to add tests of change behaviour.
This ranges from:
---
assertTrue(uri.toString().endsWith("/"))
---
which is called for multiple URIs but doesn't report the URI for which that assert fails.
To:
---
try {
reader.read(null);
assertTrue(false);
} catch (NullPointerException expected) { }
---
which is much more clearly/idiomatically expressed as:
---
assertThrows(NullPointerException.class, () -> reader.read(null));
---
It also uses TestNG, in which expected/actual parameters are reversed from JUnit, which is a cause of potential confusion while debugging.
Since I am about to add and/or modify some tests in this class (in lworld), it would be useful to first update it to JUnit, use more idiomatic asserts and add better context to assertions where needed.
This ranges from:
---
assertTrue(uri.toString().endsWith("/"))
---
which is called for multiple URIs but doesn't report the URI for which that assert fails.
To:
---
try {
reader.read(null);
assertTrue(false);
} catch (NullPointerException expected) { }
---
which is much more clearly/idiomatically expressed as:
---
assertThrows(NullPointerException.class, () -> reader.read(null));
---
It also uses TestNG, in which expected/actual parameters are reversed from JUnit, which is a cause of potential confusion while debugging.
Since I am about to add and/or modify some tests in this class (in lworld), it would be useful to first update it to JUnit, use more idiomatic asserts and add better context to assertions where needed.
- is cloned by
-
JDK-8377362 [lworld] CLONE - Update ModuleReaderTest to JUnit prior to making changes
-
- Resolved
-
- relates to
-
JDK-8377162 [lworld] getResourceAsStream() doesn't work in preview mode for exploded images
-
- Resolved
-
- links to
-
Commit(master)
openjdk/jdk/4e6cf8f5
-
Review(master)
openjdk/jdk/29588