From 46a358da97a47a47c85f20836f3a41c584ec7902 Mon Sep 17 00:00:00 2001 From: kske Date: Wed, 24 Nov 2021 12:52:59 +0100 Subject: [PATCH] Make unit tests executable by Maven --- event-bus-core/pom.xml | 11 ++++++++++- .../test/java/dev/kske/eventbus/core/CancelTest.java | 6 +++--- .../test/java/dev/kske/eventbus/core/DeadTest.java | 10 +++++----- .../java/dev/kske/eventbus/core/DispatchTest.java | 8 ++++---- .../java/dev/kske/eventbus/core/ExceptionTest.java | 12 ++++++------ .../test/java/dev/kske/eventbus/core/NestedTest.java | 6 +++--- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/event-bus-core/pom.xml b/event-bus-core/pom.xml index 91764fe..98bff14 100644 --- a/event-bus-core/pom.xml +++ b/event-bus-core/pom.xml @@ -16,7 +16,7 @@ org.junit.jupiter junit-jupiter-api - 5.6.2 + 5.8.1 test @@ -26,5 +26,14 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + \ No newline at end of file diff --git a/event-bus-core/src/test/java/dev/kske/eventbus/core/CancelTest.java b/event-bus-core/src/test/java/dev/kske/eventbus/core/CancelTest.java index 5f715c7..581f300 100644 --- a/event-bus-core/src/test/java/dev/kske/eventbus/core/CancelTest.java +++ b/event-bus-core/src/test/java/dev/kske/eventbus/core/CancelTest.java @@ -11,7 +11,7 @@ import org.junit.jupiter.api.*; * @author Leon Hofmeister * @since 0.1.0 */ -class CancelTest { +public class CancelTest { EventBus bus; int hits; @@ -22,7 +22,7 @@ class CancelTest { * @since 0.1.0 */ @BeforeEach - void registerListener() { + public void registerListener() { bus = new EventBus(); bus.registerListener(this); } @@ -34,7 +34,7 @@ class CancelTest { * @since 0.1.0 */ @Test - void testCancellation() { + public void testCancellation() { bus.dispatch(new SimpleEvent()); assertEquals(1, hits); } diff --git a/event-bus-core/src/test/java/dev/kske/eventbus/core/DeadTest.java b/event-bus-core/src/test/java/dev/kske/eventbus/core/DeadTest.java index d4efa95..ac4d862 100644 --- a/event-bus-core/src/test/java/dev/kske/eventbus/core/DeadTest.java +++ b/event-bus-core/src/test/java/dev/kske/eventbus/core/DeadTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; * @author Kai S. K. Engelbart * @since 1.1.0 */ -class DeadTest { +public class DeadTest { EventBus bus = new EventBus(); String event = "This event has no handler"; @@ -18,11 +18,11 @@ class DeadTest { /** * Tests dead event delivery. - * + * * @since 1.1.0 */ @Test - void testDeadEvent() { + public void testDeadEvent() { bus.registerListener(this); bus.dispatch(event); assertTrue(deadEventHandled); @@ -32,11 +32,11 @@ class DeadTest { /** * Tests how the event bus reacts to an unhandled dead event. This should not lead to an * exception or an endless recursion and should be logged instead. - * + * * @since 1.1.0 */ @Test - void testUnhandledDeadEvent() { + public void testUnhandledDeadEvent() { bus.dispatch(event); } diff --git a/event-bus-core/src/test/java/dev/kske/eventbus/core/DispatchTest.java b/event-bus-core/src/test/java/dev/kske/eventbus/core/DispatchTest.java index 250fc26..2fb4d31 100644 --- a/event-bus-core/src/test/java/dev/kske/eventbus/core/DispatchTest.java +++ b/event-bus-core/src/test/java/dev/kske/eventbus/core/DispatchTest.java @@ -12,7 +12,7 @@ import org.junit.jupiter.api.*; */ @Polymorphic @Priority(150) -class DispatchTest { +public class DispatchTest { EventBus bus; static int hits; @@ -23,7 +23,7 @@ class DispatchTest { * @since 0.0.1 */ @BeforeEach - void registerListener() { + public void registerListener() { bus = new EventBus(); bus.registerListener(this); bus.registerListener(SimpleEvent.class, e -> { @@ -39,7 +39,7 @@ class DispatchTest { * @since 0.0.1 */ @Test - void testDispatch() { + public void testDispatch() { bus.dispatch(new SimpleEventSub()); bus.dispatch(new SimpleEvent()); } @@ -50,7 +50,7 @@ class DispatchTest { * @since 1.2.0 */ @Test - void testPrintExecutionOrder() { + public void testPrintExecutionOrder() { String executionOrder = bus.printExecutionOrder(SimpleEvent.class); System.out.println(executionOrder); assertEquals( diff --git a/event-bus-core/src/test/java/dev/kske/eventbus/core/ExceptionTest.java b/event-bus-core/src/test/java/dev/kske/eventbus/core/ExceptionTest.java index e862036..fcc4b61 100644 --- a/event-bus-core/src/test/java/dev/kske/eventbus/core/ExceptionTest.java +++ b/event-bus-core/src/test/java/dev/kske/eventbus/core/ExceptionTest.java @@ -6,11 +6,11 @@ import org.junit.jupiter.api.Test; /** * Tests the dispatching of an exception event if an event handler threw an exception. - * + * * @author Kai S. K. Engelbart * @since 1.1.0 */ -class ExceptionTest { +public class ExceptionTest { EventBus bus = new EventBus(); String event = "This event will cause an exception"; @@ -19,11 +19,11 @@ class ExceptionTest { /** * Tests exception event delivery. - * + * * @since 1.1.0 */ @Test - void testExceptionEvent() { + public void testExceptionEvent() { bus.registerListener(this); bus.registerListener(new ExceptionListener()); bus.dispatch(event); @@ -34,11 +34,11 @@ class ExceptionTest { /** * Tests how the event bus reacts to an unhandled exception event. This should not lead to an * exception or an endless recursion and should be logged instead. - * + * * @since 1.1.0 */ @Test - void testUnhandledExceptionEvent() { + public void testUnhandledExceptionEvent() { bus.registerListener(this); bus.dispatch(event); bus.removeListener(this); diff --git a/event-bus-core/src/test/java/dev/kske/eventbus/core/NestedTest.java b/event-bus-core/src/test/java/dev/kske/eventbus/core/NestedTest.java index bb0670e..c8d3862 100644 --- a/event-bus-core/src/test/java/dev/kske/eventbus/core/NestedTest.java +++ b/event-bus-core/src/test/java/dev/kske/eventbus/core/NestedTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.*; * @author Kai S. K. Engelbart * @since 1.2.0 */ -class NestedTest { +public class NestedTest { EventBus bus; boolean nestedHit; @@ -21,7 +21,7 @@ class NestedTest { * @since 1.2.0 */ @BeforeEach - void registerListener() { + public void registerListener() { bus = new EventBus(); bus.registerListener(this); } @@ -34,7 +34,7 @@ class NestedTest { * @since 1.2.0 */ @Test - void testNestedDispatch() { + public void testNestedDispatch() { bus.dispatch(new SimpleEvent()); assertTrue(nestedHit); } -- 2.45.2