Add TestBase#performMethodCalls method
This commit is contained in:
parent
fbcb00c481
commit
6785ec64d3
12 changed files with 38 additions and 23 deletions
|
@ -42,8 +42,8 @@ class EngineConfigurationTest extends TestBase {
|
|||
@Test
|
||||
@DisplayName("Method loadConfiguration")
|
||||
void testLoadConfiguration() {
|
||||
if (isRestricted()) return;
|
||||
getLogger().testCall("testLoadConfiguration");
|
||||
if (performMethodCalls("testLoadConfiguration"))
|
||||
return;
|
||||
|
||||
Map<@NotNull String, @NotNull Object[]> settings = new HashMap<>();
|
||||
Map<@NotNull String, @NotNull Object> defaultValues = new HashMap<>();
|
||||
|
|
|
@ -151,6 +151,21 @@ public class TestBase {
|
|||
return isRestricted(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes all the necessary calls your method likely executes upon being invoked.
|
||||
* Those being:
|
||||
* - {@link #isRestricted()}
|
||||
* - {@link UnitLogger#testCall(String, Object...)}
|
||||
*
|
||||
* Make sure return if this method returns {@code true}.
|
||||
*/
|
||||
protected final boolean performMethodCalls(@NotNull String method, @NotNull Object... arguments) {
|
||||
if (isRestricted())
|
||||
return true;
|
||||
logger.testCall(method, arguments);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the engine before running tests.
|
||||
*/
|
||||
|
|
|
@ -49,8 +49,8 @@ public class FourNumberVersioningSystemTest extends TestBase {
|
|||
"1.1.0.0, 1.1.1.1, 2",
|
||||
})
|
||||
void testCompare(String a, String b, int expected) throws Throwable {
|
||||
if (isRestricted()) return;
|
||||
getLogger().testCall("testCompare", a, b, expected);
|
||||
if (performMethodCalls("testCompare", a, b, expected))
|
||||
return;
|
||||
|
||||
try {
|
||||
assertEquals(expected, new FourNumberVersioningSystem(a).compare(new FourNumberVersioningSystem(b)));
|
||||
|
|
|
@ -46,8 +46,8 @@ public class OneNumberVersioningSystemTest extends TestBase {
|
|||
"1, 2, 2",
|
||||
})
|
||||
void testCompare(String a, String b, int expected) throws Throwable {
|
||||
if (isRestricted()) return;
|
||||
getLogger().testCall("testCompare", a, b, expected);
|
||||
if (performMethodCalls("testCompare", a, b, expected))
|
||||
return;
|
||||
|
||||
try {
|
||||
assertEquals(expected, new OneNumberVersioningSystem(a).compare(new OneNumberVersioningSystem(b)));
|
||||
|
|
|
@ -54,8 +54,8 @@ public class SemanticVersioningSystemTest extends TestBase {
|
|||
"1.1.0+5, 1.1.0+6, 2",
|
||||
})
|
||||
void testCompare(String a, String b, int expected) throws Throwable {
|
||||
if (isRestricted()) return;
|
||||
getLogger().testCall("testCompare", a, b, expected);
|
||||
if (performMethodCalls("testCompare", a, b, expected))
|
||||
return;
|
||||
|
||||
try {
|
||||
assertEquals(expected, new SemanticVersioningSystem(a).compare(new SemanticVersioningSystem(b)));
|
||||
|
|
|
@ -53,8 +53,8 @@ public class StarOpenSourceVersioningSystemTest extends TestBase {
|
|||
"v9-beta5, v9-releasecandidate1, 2",
|
||||
})
|
||||
void testCompare(String a, String b, int expected) throws Throwable {
|
||||
if (isRestricted()) return;
|
||||
getLogger().testCall("testCompare", a, b, expected);
|
||||
if (performMethodCalls("testCompare", a, b, expected))
|
||||
return;
|
||||
|
||||
try {
|
||||
assertEquals(expected, new StarOpenSourceVersioningSystem(a).compare(new StarOpenSourceVersioningSystem(b)));
|
||||
|
|
|
@ -45,8 +45,8 @@ public class ThreeNumberVersioningSystemTest extends TestBase {
|
|||
"1.1.0, 1.1.1, 2",
|
||||
})
|
||||
void testCompare(String a, String b, int expected) throws Throwable {
|
||||
if (isRestricted()) return;
|
||||
getLogger().testCall("testCompare", a, b, expected);
|
||||
if (performMethodCalls("testCompare", a, b, expected))
|
||||
return;
|
||||
|
||||
try {
|
||||
assertEquals(expected, new ThreeNumberVersioningSystem(a).compare(new ThreeNumberVersioningSystem(b)));
|
||||
|
|
|
@ -45,8 +45,8 @@ public class TwoNumberVersioningSystemTest extends TestBase {
|
|||
"1.5, 2.0, 2",
|
||||
})
|
||||
void testCompare(String a, String b, int expected) throws Throwable {
|
||||
if (isRestricted()) return;
|
||||
getLogger().testCall("testCompare", a, b, expected);
|
||||
if (performMethodCalls("testCompare", a, b, expected))
|
||||
return;
|
||||
|
||||
try {
|
||||
assertEquals(expected, new TwoNumberVersioningSystem(a).compare(new TwoNumberVersioningSystem(b)));
|
||||
|
|
|
@ -46,9 +46,9 @@ class DependencyResolverTest extends TestBase {
|
|||
0, 1, 2, 3
|
||||
})
|
||||
void testResolve(int layers) {
|
||||
if (isRestricted()) return;
|
||||
if (performMethodCalls("testResolve", layers))
|
||||
return;
|
||||
|
||||
getLogger().testCall("testResolve", layers);
|
||||
DependencyResolver resolver = new DependencyResolver();
|
||||
Set<@NotNull DependencyVector> vectors = new HashSet<>();
|
||||
Set<@NotNull String> dependencies = new HashSet<>();
|
||||
|
|
|
@ -62,9 +62,9 @@ public class MiscellaneousTest extends TestBase {
|
|||
"5819853, 10, 0005819853"
|
||||
})
|
||||
void testPadNumbers(int number, int length, String expected) {
|
||||
if (isRestricted()) return;
|
||||
if (performMethodCalls("testPadNumbers", number, length, expected))
|
||||
return;
|
||||
|
||||
getLogger().testCall("testPadNumbers", number, length, expected);
|
||||
String result = Math.padNumbers(number, length);
|
||||
assertEquals(expected, result, "Result \"" + result + "\" does not match expected output \"" + expected + "\"");
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ class PlaceholderEngineTest extends TestBase {
|
|||
"This %status%!, This works!",
|
||||
})
|
||||
void testProcess(String text, String expected) {
|
||||
if (isRestricted()) return;
|
||||
getLogger().testCall("testProcess", text, expected);
|
||||
if (performMethodCalls("testProcess", text, expected))
|
||||
return;
|
||||
|
||||
List<@NotNull Placeholder> placeholders = new ArrayList<>();
|
||||
placeholders.add(new Placeholder() {
|
||||
|
|
|
@ -46,8 +46,8 @@ class PropertiesReaderTest extends TestBase {
|
|||
"a.property.mightLookLikeThis, some value"
|
||||
})
|
||||
void testGetString(String propertyName, String propertyValue) {
|
||||
if (isRestricted()) return;
|
||||
getLogger().testCall("testGetString", propertyName, propertyValue);
|
||||
if (performMethodCalls("testGetString", propertyName, propertyValue))
|
||||
return;
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(propertyName, propertyValue);
|
||||
|
|
Loading…
Reference in a new issue