Repository: Unleash/unleash-client-java
Pull request #52 (2018-06-20 15:14:47)

Upgrade to Junit5
Todo:

- [x] Migrate all tests to use junit5 and not junit4
- [x] Fix coverage. Might need to switch to Jacoco 

coveralls: 
[![Coverage Status](https://coveralls.io/builds/17593471/badge)](https://coveralls.io/builds/17593471)

Coverage remained the same at 95.248% when pulling **037f3c261f9cf324abc2be4dc7098d8d46404fa1 on junit5** into **2b6ffb801a8c104713637b2e09ce853fb5d5b8e1 on master**.


Patch:
diff --git a/pom.xml b/pom.xml
index b961da2e..9caac977 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,23 +59,52 @@
         
         <!-- Test dependencies -->
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.11</version>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <version>5.2.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-params</artifactId>
+            <version>5.2.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- Legacy support -->
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <version>5.2.0</version>
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-all</artifactId>
+            <version>1.3</version>
+            <scope>test</scope>
+        </dependency>
+
+
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-all</artifactId>
-            <version>1.9.5</version>
+            <version>1.10.19</version>
             <scope>test</scope>
         </dependency>
 
         <dependency>
             <groupId>com.github.tomakehurst</groupId>
             <artifactId>wiremock</artifactId>
-            <version>1.50</version>
+            <version>2.18.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.JensPiegsa</groupId>
+            <artifactId>wiremock-extension</artifactId>
+            <version>0.1.2</version>
             <scope>test</scope>
         </dependency>
 
@@ -99,6 +128,10 @@
                     <target>1.8</target>
                 </configuration>
             </plugin>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.22.0</version>
+            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-jar-plugin</artifactId>
@@ -145,4 +178,11 @@
         </plugins>
     </build>
 
+    <repositories>
+        <repository>
+            <id>jitpack.io</id>
+            <url>https://jitpack.io</url>
+        </repository>
+    </repositories>
+
 </project>


Test patch:
diff --git a/src/test/java/no/finn/unleash/FakeUnleashTest.java b/src/test/java/no/finn/unleash/FakeUnleashTest.java
index d1dc9593..a2b9bc36 100644
--- a/src/test/java/no/finn/unleash/FakeUnleashTest.java
+++ b/src/test/java/no/finn/unleash/FakeUnleashTest.java
@@ -1,12 +1,13 @@
 package no.finn.unleash;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.util.Arrays;
 import java.util.List;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class FakeUnleashTest {
 
@@ -85,7 +86,6 @@ public class FakeUnleashTest {
 
     }
 
-
     @Test
     public void should_get_all_feature_names() {
         FakeUnleash fakeUnleash = new FakeUnleash();
diff --git a/src/test/java/no/finn/unleash/UnleashTest.java b/src/test/java/no/finn/unleash/UnleashTest.java
index 45989121..4ca00566 100644
--- a/src/test/java/no/finn/unleash/UnleashTest.java
+++ b/src/test/java/no/finn/unleash/UnleashTest.java
@@ -9,12 +9,12 @@ import no.finn.unleash.repository.ToggleRepository;
 import no.finn.unleash.strategy.Strategy;
 import no.finn.unleash.strategy.UserWithIdStrategy;
 import no.finn.unleash.util.UnleashConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.anyMap;
 import static org.mockito.Mockito.mock;
@@ -28,7 +28,7 @@ public class UnleashTest {
     private UnleashContextProvider contextProvider;
     private Unleash unleash;
 
-    @Before
+    @BeforeEach
     public void setup() {
         toggleRepository = mock(ToggleRepository.class);
         contextProvider = mock(UnleashContextProvider.class);
@@ -133,7 +133,6 @@ public class UnleashTest {
         assertThat(unleash.isEnabled("test", context), is(true));
     }
 
-
     @Test
     public void inactive_feature_toggle() {
         ActivationStrategy strategy1 = new ActivationStrategy("unknown", null);
diff --git a/src/test/java/no/finn/unleash/example/UnleashUsageTest.java b/src/test/java/no/finn/unleash/example/UnleashUsageTest.java
index fdf6fe3d..0bdf541b 100644
--- a/src/test/java/no/finn/unleash/example/UnleashUsageTest.java
+++ b/src/test/java/no/finn/unleash/example/UnleashUsageTest.java
@@ -3,9 +3,9 @@ package no.finn.unleash.example;
 import no.finn.unleash.DefaultUnleash;
 import no.finn.unleash.Unleash;
 import no.finn.unleash.util.UnleashConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
 public class UnleashUsageTest {
 
diff --git a/src/test/java/no/finn/unleash/metric/UnleashMetricServiceImplTest.java b/src/test/java/no/finn/unleash/metric/UnleashMetricServiceImplTest.java
index 44745e0c..302f4d49 100644
--- a/src/test/java/no/finn/unleash/metric/UnleashMetricServiceImplTest.java
+++ b/src/test/java/no/finn/unleash/metric/UnleashMetricServiceImplTest.java
@@ -3,17 +3,17 @@ package no.finn.unleash.metric;
 import no.finn.unleash.util.UnleashConfig;
 import no.finn.unleash.util.UnleashScheduledExecutor;
 import org.hamcrest.core.IsNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 
 import java.util.HashSet;
 import java.util.Set;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Matchers.*;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
diff --git a/src/test/java/no/finn/unleash/metric/UnleashMetricsSenderTest.java b/src/test/java/no/finn/unleash/metric/UnleashMetricsSenderTest.java
index 3682e6d4..d2f257af 100644
--- a/src/test/java/no/finn/unleash/metric/UnleashMetricsSenderTest.java
+++ b/src/test/java/no/finn/unleash/metric/UnleashMetricsSenderTest.java
@@ -1,10 +1,14 @@
 package no.finn.unleash.metric;
 
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
+import com.github.jenspiegsa.mockitoextension.ConfigureWireMock;
+import com.github.jenspiegsa.mockitoextension.InjectServer;
+import com.github.jenspiegsa.mockitoextension.WireMockExtension;
+import com.github.jenspiegsa.mockitoextension.WireMockSettings;
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.core.Options;
 import no.finn.unleash.util.UnleashConfig;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -13,13 +17,18 @@ import java.util.HashSet;
 
 import static com.github.tomakehurst.wiremock.client.WireMock.*;
 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
 
+@ExtendWith(WireMockExtension.class)
+@WireMockSettings(failOnUnmatchedRequests = false)
 public class UnleashMetricsSenderTest {
-    @Rule
-    public WireMockRule wireMockRule = new WireMockRule(0);
 
-    @Rule
-    public ExpectedException exception = ExpectedException.none();
+    @ConfigureWireMock
+    Options options = wireMockConfig()
+            .dynamicPort();
+
+    @InjectServer
+    WireMockServer serverMock;
 
     @Test
     public void should_send_client_registration() throws URISyntaxException {
@@ -27,7 +36,7 @@ public class UnleashMetricsSenderTest {
                 .withHeader("UNLEASH-APPNAME", matching("test-app"))
                 .willReturn(aResponse().withStatus(200)));
 
-        URI uri = new URI("http://localhost:"+wireMockRule.port());
+        URI uri = new URI("http://localhost:"+serverMock.port());
         UnleashConfig config = UnleashConfig.builder().appName("test-app").unleashAPI(uri).build();
 
         UnleashMetricsSender sender = new UnleashMetricsSender(config);
@@ -45,7 +54,7 @@ public class UnleashMetricsSenderTest {
                 .withHeader("UNLEASH-APPNAME", matching("test-app"))
                 .willReturn(aResponse().withStatus(200)));
 
-        URI uri = new URI("http://localhost:"+wireMockRule.port());
+        URI uri = new URI("http://localhost:"+serverMock.port());
         UnleashConfig config = UnleashConfig.builder().appName("test-app").unleashAPI(uri).build();
 
         UnleashMetricsSender sender = new UnleashMetricsSender(config);
@@ -65,7 +74,7 @@ public class UnleashMetricsSenderTest {
                 .withHeader("UNLEASH-APPNAME", matching("test-app"))
                 .willReturn(aResponse().withStatus(500)));
 
-        URI uri = new URI("http://localhost:"+wireMockRule.port());
+        URI uri = new URI("http://localhost:"+serverMock.port());
         UnleashConfig config = UnleashConfig.builder().appName("test-app").unleashAPI(uri).build();
 
         UnleashMetricsSender sender = new UnleashMetricsSender(config);
diff --git a/src/test/java/no/finn/unleash/repository/FeatureToggleRepositoryTest.java b/src/test/java/no/finn/unleash/repository/FeatureToggleRepositoryTest.java
index 7a721902..8ddd20b6 100644
--- a/src/test/java/no/finn/unleash/repository/FeatureToggleRepositoryTest.java
+++ b/src/test/java/no/finn/unleash/repository/FeatureToggleRepositoryTest.java
@@ -4,7 +4,7 @@ import no.finn.unleash.ActivationStrategy;
 import no.finn.unleash.FeatureToggle;
 import no.finn.unleash.util.UnleashConfig;
 import no.finn.unleash.util.UnleashScheduledExecutor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 
 import java.net.URISyntaxException;
@@ -12,8 +12,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.*;
 
 
@@ -28,7 +28,7 @@ public class FeatureToggleRepositoryTest {
         ToggleBackupHandler toggleBackupHandler = new ToggleBackupHandlerFile(config);
         UnleashScheduledExecutor executor = mock(UnleashScheduledExecutor.class);
         ToggleRepository toggleRepository = new FeatureToggleRepository(config, executor, toggleFetcher, toggleBackupHandler);
-        assertNull("should be null", toggleRepository.getToggle("unknownFeature"));
+        assertNull(toggleRepository.getToggle("unknownFeature"), "should be null");
     }
 
     @Test
diff --git a/src/test/java/no/finn/unleash/repository/HttpToggleFetcherTest.java b/src/test/java/no/finn/unleash/repository/HttpToggleFetcherTest.java
index 7fe27fa2..68bce871 100644
--- a/src/test/java/no/finn/unleash/repository/HttpToggleFetcherTest.java
+++ b/src/test/java/no/finn/unleash/repository/HttpToggleFetcherTest.java
@@ -1,25 +1,34 @@
 package no.finn.unleash.repository;
 
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
+import com.github.jenspiegsa.mockitoextension.ConfigureWireMock;
+import com.github.jenspiegsa.mockitoextension.InjectServer;
+import com.github.jenspiegsa.mockitoextension.WireMockExtension;
+import com.github.jenspiegsa.mockitoextension.WireMockSettings;
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.core.Options;
 import no.finn.unleash.FeatureToggle;
-import no.finn.unleash.UnleashException;
 import no.finn.unleash.util.UnleashConfig;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 
 import java.net.URI;
 import java.net.URISyntaxException;
 
 import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static org.junit.Assert.*;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
+@ExtendWith(WireMockExtension.class)
+@WireMockSettings(failOnUnmatchedRequests = false)
 public class HttpToggleFetcherTest {
-    @Rule
-    public WireMockRule wireMockRule = new WireMockRule(0);
 
-    @Rule
-    public ExpectedException exception = ExpectedException.none();
+    @ConfigureWireMock
+    Options options = wireMockConfig()
+            .dynamicPort();
+
+    @InjectServer
+    WireMockServer serverMock;
 
     /*
     @Test
@@ -49,7 +58,7 @@ public class HttpToggleFetcherTest {
                         .withHeader("Content-Type", "application/json")
                         .withBodyFile("features-v0.json")));
 
-        URI uri = new URI("http://localhost:"+wireMockRule.port() + "/api/");
+        URI uri = new URI("http://localhost:"+serverMock.port() + "/api/");
         UnleashConfig config = UnleashConfig.builder().appName("test").unleashAPI(uri).build();
         HttpToggleFetcher httpToggleFetcher = new HttpToggleFetcher(config);
         FeatureToggleResponse response = httpToggleFetcher.fetchToggles();
@@ -70,7 +79,7 @@ public class HttpToggleFetcherTest {
                         .withHeader("Content-Type", "application/json")
                         .withBodyFile("features-v1.json")));
 
-        URI uri = new URI("http://localhost:"+wireMockRule.port() + "/api/");
+        URI uri = new URI("http://localhost:"+serverMock.port() + "/api/");
         UnleashConfig config = UnleashConfig.builder().appName("test").unleashAPI(uri).build();
         HttpToggleFetcher httpToggleFetcher = new HttpToggleFetcher(config);
         FeatureToggleResponse response = httpToggleFetcher.fetchToggles();
@@ -82,8 +91,8 @@ public class HttpToggleFetcherTest {
                 .withHeader("Content-Type", matching("application/json")));
     }
 
-
     @Test
+    @ExtendWith(UnleashExceptionExtension.class)
     public void given_empty_body() throws URISyntaxException {
         stubFor(get(urlEqualTo("/api/client/features"))
                 .withHeader("Accept", equalTo("application/json"))
@@ -91,10 +100,9 @@ public class HttpToggleFetcherTest {
                         .withStatus(200)
                         .withHeader("Content-Type", "application/json")));
 
-        URI uri = new URI("http://localhost:"+wireMockRule.port() + "/api/");
+        URI uri = new URI("http://localhost:"+serverMock.port() + "/api/");
         UnleashConfig config = UnleashConfig.builder().appName("test").unleashAPI(uri).build();
         HttpToggleFetcher httpToggleFetcher = new HttpToggleFetcher(config);
-        exception.expect(UnleashException.class);
         httpToggleFetcher.fetchToggles();
 
 
@@ -103,6 +111,7 @@ public class HttpToggleFetcherTest {
     }
 
     @Test
+    @ExtendWith(UnleashExceptionExtension.class)
     public void given_json_without_feature_field() throws Exception {
         stubFor(get(urlEqualTo("/api/client/features"))
                 .withHeader("Accept", equalTo("application/json"))
@@ -111,10 +120,9 @@ public class HttpToggleFetcherTest {
                         .withHeader("Content-Type", "application/json")
                         .withBody("{}")));
 
-        URI uri = new URI("http://localhost:"+wireMockRule.port() + "/api/");
+        URI uri = new URI("http://localhost:"+serverMock.port() + "/api/");
         UnleashConfig config = UnleashConfig.builder().appName("test").unleashAPI(uri).build();
         HttpToggleFetcher httpToggleFetcher = new HttpToggleFetcher(config);
-        exception.expect(UnleashException.class);
         httpToggleFetcher.fetchToggles();
 
         verify(getRequestedFor(urlMatching("/api/client/features"))
@@ -129,11 +137,12 @@ public class HttpToggleFetcherTest {
                         .withStatus(304)
                         .withHeader("Content-Type", "application/json")));
 
-        URI uri = new URI("http://localhost:"+wireMockRule.port() + "/api/");
+        URI uri = new URI("http://localhost:"+serverMock.port() + "/api/");
         UnleashConfig config = UnleashConfig.builder().appName("test").unleashAPI(uri).build();
         HttpToggleFetcher httpToggleFetcher = new HttpToggleFetcher(config);
         FeatureToggleResponse response = httpToggleFetcher.fetchToggles();
-        assertEquals("Should return status NOT_CHANGED", response.getStatus(), FeatureToggleResponse.Status.NOT_CHANGED);
+        assertEquals(response.getStatus(), FeatureToggleResponse.Status.NOT_CHANGED,
+                "Should return status NOT_CHANGED");
 
         verify(getRequestedFor(urlMatching("/api/client/features"))
                 .withHeader("Content-Type", matching("application/json")));
@@ -150,11 +159,12 @@ public class HttpToggleFetcherTest {
                             .withStatus(httpCode)
                             .withHeader("Content-Type", "application/json")));
 
-            URI uri = new URI("http://localhost:" + wireMockRule.port() + "/api/");
+            URI uri = new URI("http://localhost:" + serverMock.port() + "/api/");
             UnleashConfig config = UnleashConfig.builder().appName("test").unleashAPI(uri).build();
             HttpToggleFetcher httpToggleFetcher = new HttpToggleFetcher(config);
             FeatureToggleResponse response = httpToggleFetcher.fetchToggles();
-            assertEquals("Should return status UNAVAILABLE", response.getStatus(), FeatureToggleResponse.Status.UNAVAILABLE);
+            assertEquals(response.getStatus(), FeatureToggleResponse.Status.UNAVAILABLE,
+                    "Should return status UNAVAILABLE");
 
             verify(getRequestedFor(urlMatching("/api/client/features"))
                     .withHeader("Content-Type", matching("application/json")));
diff --git a/src/test/java/no/finn/unleash/repository/JsonFeatureToggleParserTest.java b/src/test/java/no/finn/unleash/repository/JsonFeatureToggleParserTest.java
index b3f9694b..4655b0c4 100644
--- a/src/test/java/no/finn/unleash/repository/JsonFeatureToggleParserTest.java
+++ b/src/test/java/no/finn/unleash/repository/JsonFeatureToggleParserTest.java
@@ -1,14 +1,14 @@
 package no.finn.unleash.repository;
 
 import no.finn.unleash.FeatureToggle;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.*;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class JsonFeatureToggleParserTest {
 
@@ -67,21 +67,13 @@ public class JsonFeatureToggleParserTest {
     @Test
     public void should_throw() throws IOException {
         Reader content = getFileReader("/empty.json");
-        try {
-            JsonToggleParser.fromJson(content);
-        } catch (IllegalStateException e) {
-            assertTrue("Expected IllegalStateException", e instanceof IllegalStateException);
-        }
+        assertThrows(IllegalStateException.class, () -> JsonToggleParser.fromJson(content));
     }
 
     @Test
     public void should_throw_on_mission_features() throws IOException {
         Reader content = getFileReader("/empty-v1.json");
-        try {
-            JsonToggleParser.fromJson(content);
-        } catch (IllegalStateException e) {
-            assertTrue("Expected IllegalStateException", e instanceof IllegalStateException);
-        }
+        assertThrows(IllegalStateException.class, () -> JsonToggleParser.fromJson(content));
     }
 
     @Test
diff --git a/src/test/java/no/finn/unleash/repository/ToggleBackupHandlerFileTest.java b/src/test/java/no/finn/unleash/repository/ToggleBackupHandlerFileTest.java
index 45c6c979..1f69e323 100644
--- a/src/test/java/no/finn/unleash/repository/ToggleBackupHandlerFileTest.java
+++ b/src/test/java/no/finn/unleash/repository/ToggleBackupHandlerFileTest.java
@@ -6,11 +6,11 @@ import java.io.StringReader;
 import java.net.URISyntaxException;
 
 import no.finn.unleash.util.UnleashConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 public class ToggleBackupHandlerFileTest {
@@ -24,7 +24,9 @@ public class ToggleBackupHandlerFileTest {
                 .build();
         ToggleBackupHandlerFile toggleBackupHandlerFile = new ToggleBackupHandlerFile(config);
         ToggleCollection toggleCollection = toggleBackupHandlerFile.read();
-        assertNotNull("presentFeature should be present", toggleCollection.getToggle("presentFeature"));
+
+        assertNotNull(toggleCollection.getToggle("presentFeature"),
+                "presentFeature should be present");
     }
 
     @Test
@@ -50,7 +52,8 @@ public class ToggleBackupHandlerFileTest {
         ToggleBackupHandlerFile toggleBackupHandlerFile = new ToggleBackupHandlerFile(config);
         ToggleCollection toggleCollection = toggleBackupHandlerFile.read();
 
-        assertNull("presentFeature should not be present", toggleCollection.getToggle("presentFeature"));
+        assertNull(toggleCollection.getToggle("presentFeature"),
+                "presentFeature should not be present");
     }
 
     @Test
@@ -70,7 +73,7 @@ public class ToggleBackupHandlerFileTest {
         toggleBackupHandlerFile.write(toggleCollection);
         toggleBackupHandlerFile = new ToggleBackupHandlerFile(config);
         toggleCollection = toggleBackupHandlerFile.read();
-        assertNotNull("writableFeature should be present", toggleCollection.getToggle("writableFeature"));
+        assertNotNull(toggleCollection.getToggle("writableFeature"), "writableFeature should be present");
     }
 
     @Test
@@ -83,8 +86,8 @@ public class ToggleBackupHandlerFileTest {
 
         ToggleBackupHandlerFile toggleBackupHandlerFile = new ToggleBackupHandlerFile(config);
         ToggleCollection toggleCollection = toggleBackupHandlerFile.read();
-        assertNotNull("presentFeature should be present", toggleCollection.getToggle("featureCustomStrategy"));
-        assertEquals("should have 1 strategy", toggleCollection.getToggle("featureCustomStrategy").getStrategies().size(), 1);
+        assertNotNull(toggleCollection.getToggle("featureCustomStrategy"), "presentFeature should be present");
+        assertEquals(toggleCollection.getToggle("featureCustomStrategy").getStrategies().size(), 1, "should have 1 strategy");
         assertEquals(toggleCollection.getToggle("featureCustomStrategy").getStrategies().get(0).getParameters().get("customParameter"), "customValue");
     }
 
diff --git a/src/test/java/no/finn/unleash/repository/UnleashExceptionExtension.java b/src/test/java/no/finn/unleash/repository/UnleashExceptionExtension.java
new file mode 100644
index 00000000..d5640d2a
--- /dev/null
+++ b/src/test/java/no/finn/unleash/repository/UnleashExceptionExtension.java
@@ -0,0 +1,15 @@
+package no.finn.unleash.repository;
+
+import no.finn.unleash.UnleashException;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
+
+public class UnleashExceptionExtension implements TestExecutionExceptionHandler {
+    @Override
+    public void handleTestExecutionException(ExtensionContext extensionContext, Throwable throwable) throws Throwable {
+        if (throwable instanceof UnleashException) {
+            return;
+        }
+        throw throwable;
+    }
+}
diff --git a/src/test/java/no/finn/unleash/strategy/ApplicationHostnameStrategyTest.java b/src/test/java/no/finn/unleash/strategy/ApplicationHostnameStrategyTest.java
index 87b10f6e..64e144cb 100644
--- a/src/test/java/no/finn/unleash/strategy/ApplicationHostnameStrategyTest.java
+++ b/src/test/java/no/finn/unleash/strategy/ApplicationHostnameStrategyTest.java
@@ -5,14 +5,15 @@ import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class ApplicationHostnameStrategyTest {
 
-    @After
+    @AfterEach
     public void remove_hostname_property() {
         System.getProperties().remove("hostname");
     }
diff --git a/src/test/java/no/finn/unleash/strategy/GradualRolloutRandomStrategyTest.java b/src/test/java/no/finn/unleash/strategy/GradualRolloutRandomStrategyTest.java
index 3115c174..9c614ca0 100644
--- a/src/test/java/no/finn/unleash/strategy/GradualRolloutRandomStrategyTest.java
+++ b/src/test/java/no/finn/unleash/strategy/GradualRolloutRandomStrategyTest.java
@@ -4,19 +4,19 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
 
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 
 public final class GradualRolloutRandomStrategyTest {
 
     private static GradualRolloutRandomStrategy gradualRolloutRandomStrategy;
 
-    @Before
-    public void setUp() {
+    @BeforeAll
+    public static void setUp() {
         long seed = new Random().nextLong();
         System.out.println("GradualRolloutRandomStrategyTest running with seed: " + seed);
         gradualRolloutRandomStrategy = new GradualRolloutRandomStrategy(seed);
@@ -74,7 +74,7 @@ public final class GradualRolloutRandomStrategyTest {
 
         for (int i = 0; i <= 100; i++) {
             final boolean enabled = gradualRolloutRandomStrategy.isEnabled(parameters);
-            assertTrue("Should be enabled for p=" + i, enabled);
+            assertTrue(enabled, "Should be enabled for p=" + i);
         }
     }
 
diff --git a/src/test/java/no/finn/unleash/strategy/GradualRolloutSessionIdStrategyTest.java b/src/test/java/no/finn/unleash/strategy/GradualRolloutSessionIdStrategyTest.java
index 3fc276dc..f67f7733 100644
--- a/src/test/java/no/finn/unleash/strategy/GradualRolloutSessionIdStrategyTest.java
+++ b/src/test/java/no/finn/unleash/strategy/GradualRolloutSessionIdStrategyTest.java
@@ -7,13 +7,15 @@ import java.util.Random;
 
 import com.google.common.collect.ImmutableList;
 import no.finn.unleash.UnleashContext;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class GradualRolloutSessionIdStrategyTest {
     private static final long SEED = 89235015401L;
@@ -23,7 +25,7 @@ public class GradualRolloutSessionIdStrategyTest {
     Random rand = new Random(SEED);
     List<Integer> percentages;
 
-    @Before
+    @BeforeEach
     public void init() {
         percentages = ImmutableList.<Integer>builder()
                 .add(1)
@@ -96,7 +98,7 @@ public class GradualRolloutSessionIdStrategyTest {
         Map<String, String> params = buildParams(0, "innfinn");
         boolean actual = gradualRolloutStrategy.isEnabled(params, context);
 
-        assertFalse("should not be enabled when 0% rollout", actual);
+        assertFalse(actual, "should not be enabled when 0% rollout");
     }
 
     @Test
@@ -112,12 +114,11 @@ public class GradualRolloutSessionIdStrategyTest {
         for(int p = minimumPercentage ; p <=100 ; p++) {
             Map<String, String> params = buildParams(p, groupId);
             boolean actual = gradualRolloutStrategy.isEnabled(params, context);
-            assertTrue("should be enabled when " + p + "% rollout", actual);
+            assertTrue(actual, "should be enabled when " + p + "% rollout");
         }
     }
 
-
-    @Ignore // Intended for manual execution
+    @Disabled // Intended for manual execution
     @Test
     public void generateReportForListOfLoginIDs() {
         final int numberOfIDs = 200000;
diff --git a/src/test/java/no/finn/unleash/strategy/GradualRolloutUserIdStrategyTest.java b/src/test/java/no/finn/unleash/strategy/GradualRolloutUserIdStrategyTest.java
index 9a2ddebc..aa49543a 100644
--- a/src/test/java/no/finn/unleash/strategy/GradualRolloutUserIdStrategyTest.java
+++ b/src/test/java/no/finn/unleash/strategy/GradualRolloutUserIdStrategyTest.java
@@ -7,13 +7,15 @@ import java.util.Random;
 
 import com.google.common.collect.ImmutableList;
 import no.finn.unleash.UnleashContext;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class GradualRolloutUserIdStrategyTest {
     private static final long SEED = 89235015401L;
@@ -23,7 +25,7 @@ public class GradualRolloutUserIdStrategyTest {
     Random rand = new Random(SEED);
     List<Integer> percentages;
 
-    @Before
+    @BeforeEach
     public void init() {
         percentages = ImmutableList.<Integer>builder()
                 .add(1)
@@ -96,7 +98,7 @@ public class GradualRolloutUserIdStrategyTest {
         Map<String, String> params = buildParams(0, "innfinn");
         boolean actual = gradualRolloutStrategy.isEnabled(params, context);
 
-        assertFalse("should not be enabled when 0% rollout", actual);
+        assertFalse(actual, "should not be enabled when 0% rollout");
     }
 
     @Test
@@ -112,7 +114,7 @@ public class GradualRolloutUserIdStrategyTest {
         for(int p = minimumPercentage ; p <=100 ; p++) {
             Map<String, String> params = buildParams(p, groupId);
             boolean actual = gradualRolloutStrategy.isEnabled(params, context);
-            assertTrue("should be enabled when " + p + "% rollout", actual);
+            assertTrue(actual, "should be enabled when " + p + "% rollout");
         }
     }
 
@@ -138,15 +140,15 @@ public class GradualRolloutUserIdStrategyTest {
 
         double actualPercentage = ((double) enabledCount / (double) rounds) * 100.0;
 
-        assertTrue("Expected " + percentage + "%, but was "+ actualPercentage + "%" ,
-                (percentage-1) < actualPercentage);
+        assertTrue((percentage-1) < actualPercentage,
+                "Expected " + percentage + "%, but was "+ actualPercentage + "%");
 
-        assertTrue("Expected " + percentage + "%, but was "+ actualPercentage + "%" ,
-                (percentage+1) > actualPercentage);
+        assertTrue((percentage+1) > actualPercentage,
+                "Expected " + percentage + "%, but was "+ actualPercentage + "%");
     }
 
 
-    @Ignore // Intended for manual execution
+    @Disabled // Intended for manual execution
     @Test
     public void generateReportForListOfLoginIDs() {
         final int numberOfIDs = 200000;
diff --git a/src/test/java/no/finn/unleash/strategy/RemoteAddressStrategyTest.java b/src/test/java/no/finn/unleash/strategy/RemoteAddressStrategyTest.java
index 8245c47c..f7598a35 100644
--- a/src/test/java/no/finn/unleash/strategy/RemoteAddressStrategyTest.java
+++ b/src/test/java/no/finn/unleash/strategy/RemoteAddressStrategyTest.java
@@ -4,53 +4,41 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Stream;
 
 import no.finn.unleash.UnleashContext;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
-@RunWith(Parameterized.class)
 public class RemoteAddressStrategyTest {
     private static final String FIRST_IP = "127.0.0.1";
     private static final String SECOND_IP = "10.0.0.1";
     private static final String THIRD_IP = "196.0.0.1";
     private static final List<String> ALL = Arrays.asList(FIRST_IP, SECOND_IP, THIRD_IP);
 
-    @Parameter(value=0)
-    public String actualIp;
-
-    @Parameter(value=1)
-    public String parameterString;
-
-    @Parameter(value=2)
-    public boolean expected;
-
     private RemoteAddressStrategy strategy;
 
-    @Parameters(name="{index}: actualIp: {0}, parameter: {1}, expected: {2}")
-    public static Iterable<Object[]> data() {
-        return Arrays.asList(new Object[][] {
-                {FIRST_IP, FIRST_IP, true},
-                {FIRST_IP, String.join(",", ALL), true},
-                {SECOND_IP, String.join(",", ALL), true},
-                {THIRD_IP, String.join(",", ALL), true},
-                {FIRST_IP, String.join(", ", ALL), true},
-                {SECOND_IP, String.join(", ", ALL), true},
-                {THIRD_IP, String.join(", ", ALL), true},
-                {SECOND_IP, String.join(",  ", ALL), true},
-                {SECOND_IP, String.join(".", ALL), false},
-                {FIRST_IP, SECOND_IP, false},
-        });
+    public static Stream<Arguments> data() {
+        return Stream.of(
+                Arguments.of(FIRST_IP, FIRST_IP, true),
+                Arguments.of(FIRST_IP, String.join(",", ALL), true),
+                Arguments.of(SECOND_IP, String.join(",", ALL), true),
+                Arguments.of(THIRD_IP, String.join(",", ALL), true),
+                Arguments.of(FIRST_IP, String.join(", ", ALL), true),
+                Arguments.of(SECOND_IP, String.join(", ", ALL), true),
+                Arguments.of(THIRD_IP, String.join(", ", ALL), true),
+                Arguments.of(SECOND_IP, String.join(",  ", ALL), true),
+                Arguments.of(SECOND_IP, String.join(".", ALL), false),
+                Arguments.of(FIRST_IP, SECOND_IP, false));
     }
 
-    @Before
+    @BeforeEach
     public void setUp() {
         strategy = new RemoteAddressStrategy();
     }
@@ -60,8 +48,9 @@ public class RemoteAddressStrategyTest {
         assertThat(strategy.getName(), is("remoteAddress"));
     }
 
-    @Test
-    public void test() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void test_all_combinations(String actualIp, String parameterString, boolean expected) {
         UnleashContext context = UnleashContext.builder().remoteAddress(actualIp).build();
         Map<String, String> parameters = setupParameterMap(parameterString);
 
diff --git a/src/test/java/no/finn/unleash/strategy/StrategyUtilsTest.java b/src/test/java/no/finn/unleash/strategy/StrategyUtilsTest.java
index 1a38a6a8..b26a70e1 100644
--- a/src/test/java/no/finn/unleash/strategy/StrategyUtilsTest.java
+++ b/src/test/java/no/finn/unleash/strategy/StrategyUtilsTest.java
@@ -1,8 +1,8 @@
 package no.finn.unleash.strategy;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class StrategyUtilsTest {
 
diff --git a/src/test/java/no/finn/unleash/strategy/StrategyWithContextTest.java b/src/test/java/no/finn/unleash/strategy/StrategyWithContextTest.java
index 1143b55a..a9a743a0 100644
--- a/src/test/java/no/finn/unleash/strategy/StrategyWithContextTest.java
+++ b/src/test/java/no/finn/unleash/strategy/StrategyWithContextTest.java
@@ -3,16 +3,16 @@ package no.finn.unleash.strategy;
 import java.util.HashMap;
 import java.util.Map;
 import no.finn.unleash.UnleashContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class StrategyWithContextTest {
     private StrategyUsingContext strategy;
 
-    @Before
+    @BeforeEach
     public void setup() {
         strategy = new StrategyUsingContext();
     }
diff --git a/src/test/java/no/finn/unleash/strategy/UserWithIdStrategyTest.java b/src/test/java/no/finn/unleash/strategy/UserWithIdStrategyTest.java
index 9de5a34c..8d4752e0 100644
--- a/src/test/java/no/finn/unleash/strategy/UserWithIdStrategyTest.java
+++ b/src/test/java/no/finn/unleash/strategy/UserWithIdStrategyTest.java
@@ -3,18 +3,18 @@ package no.finn.unleash.strategy;
 import java.util.HashMap;
 import java.util.Map;
 import no.finn.unleash.UnleashContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class UserWithIdStrategyTest {
     private UserWithIdStrategy strategy;
 
-    @Before
+    @BeforeEach
     public void setup() {
         strategy = new UserWithIdStrategy();
     }
diff --git a/src/test/java/no/finn/unleash/util/UnleashConfigTest.java b/src/test/java/no/finn/unleash/util/UnleashConfigTest.java
index 3fe05535..6ef7fddb 100644
--- a/src/test/java/no/finn/unleash/util/UnleashConfigTest.java
+++ b/src/test/java/no/finn/unleash/util/UnleashConfigTest.java
@@ -5,28 +5,33 @@ import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.net.URI;
 import java.net.URL;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.Executable;
 
 import static no.finn.unleash.util.UnleashConfig.UNLEASH_APP_NAME_HEADER;
 import static no.finn.unleash.util.UnleashConfig.UNLEASH_INSTANCE_ID_HEADER;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class UnleashConfigTest {
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void should_require_unleasAPI_url() {
-        UnleashConfig.builder().appName("test").build();
+        Executable ex = () -> UnleashConfig.builder().appName("test").build();
+        assertThrows(IllegalStateException.class, ex);
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void should_require_app_name() {
-        UnleashConfig.builder().unleashAPI("http://unleash.com").build();
+        Executable ex = () -> UnleashConfig.builder().unleashAPI("http://unleash.com").build();
+        assertThrows(IllegalStateException.class, ex);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void should_require_valid_uri() {
-        UnleashConfig.builder().unleashAPI("this is not a uri").build();
+        Executable ex = () -> UnleashConfig.builder().unleashAPI("this is not a uri").build();
+        assertThrows(IllegalArgumentException.class, ex);
     }
 
     @Test
diff --git a/src/test/java/no/finn/unleash/util/UnleashURLsTest.java b/src/test/java/no/finn/unleash/util/UnleashURLsTest.java
index 629fa1c1..aad4d023 100644
--- a/src/test/java/no/finn/unleash/util/UnleashURLsTest.java
+++ b/src/test/java/no/finn/unleash/util/UnleashURLsTest.java
@@ -1,11 +1,12 @@
 package no.finn.unleash.util;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.net.URI;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class UnleashURLsTest {
 
@@ -34,8 +35,8 @@ public class UnleashURLsTest {
         assertThat(urls.getFetchTogglesURL().toString(), is("http://unleash.com/api/client/features"));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test()
     public void should_throw() {
-        new UnleashURLs(URI.create("unleash.com"));
+        assertThrows(IllegalArgumentException.class, () -> new UnleashURLs(URI.create("unleash.com")));
     }
 }
\ No newline at end of file