From 8e12cbb758f3d22270aa757e7903ff43156db9ff Mon Sep 17 00:00:00 2001 From: Bartosz Miller Date: Sun, 10 Dec 2017 21:45:55 +0100 Subject: [PATCH] Delete skipTests flag and separate unit and integration tests --- .travis.yml | 2 +- jota/src/test/java/jota/IotaAPITest.java | 12 ++++++++++++ jota/src/test/java/jota/IotaCoreApiTest.java | 17 +++++++++++++++++ jota/src/test/java/jota/IotaMultisigTest.java | 3 +++ .../java/jota/category/IntegrationTest.java | 4 ++++ jota/src/test/java/jota/category/UnitTest.java | 4 ++++ pom.xml | 17 ++++++++++++++++- 7 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 jota/src/test/java/jota/category/IntegrationTest.java create mode 100644 jota/src/test/java/jota/category/UnitTest.java diff --git a/.travis.yml b/.travis.yml index 8abefd7..cff0cc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ before_install: install: # Override default travis to use the maven wrapper - - ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V + - ./mvnw install -Dmaven.javadoc.skip=true -B -V script: - .travis/publish.sh diff --git a/jota/src/test/java/jota/IotaAPITest.java b/jota/src/test/java/jota/IotaAPITest.java index 3aa2304..e3b8110 100644 --- a/jota/src/test/java/jota/IotaAPITest.java +++ b/jota/src/test/java/jota/IotaAPITest.java @@ -1,6 +1,7 @@ package jota; import com.google.gson.Gson; +import jota.category.IntegrationTest; import jota.dto.response.*; import jota.error.ArgumentException; import jota.model.Bundle; @@ -13,6 +14,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.ArrayList; import java.util.List; @@ -113,6 +115,7 @@ public class IotaAPITest { } @Test + @Category(IntegrationTest.class) public void shouldGetInputs() throws ArgumentException { GetBalancesAndFormatResponse res = iotaAPI.getInputs(TEST_SEED1, 2, 0, 0, 0); System.out.println(res); @@ -153,6 +156,7 @@ public class IotaAPITest { //seed contains 0 balance @Test(expected = IllegalStateException.class) + @Category(IntegrationTest.class) public void shouldPrepareTransfer() throws ArgumentException { List transfers = new ArrayList<>(); @@ -165,6 +169,7 @@ public class IotaAPITest { //seed contains 0 balance @Test(expected = IllegalStateException.class) + @Category(IntegrationTest.class) public void shouldPrepareTransferWithInputs() throws ArgumentException { List inputlist = new ArrayList<>(); List transfers = new ArrayList<>(); @@ -181,12 +186,14 @@ public class IotaAPITest { } @Test + @Category(IntegrationTest.class) public void shouldGetLastInclusionState() throws ArgumentException { GetInclusionStateResponse res = iotaAPI.getLatestInclusion(new String[]{TEST_HASH}); assertThat(res.getStates(), IsNull.notNullValue()); } @Test + @Category(IntegrationTest.class) public void shouldFindTransactionObjects() throws ArgumentException { List ftr = iotaAPI.findTransactionObjectsByAddresses(TEST_ADDRESSES); System.out.println(ftr); @@ -194,6 +201,7 @@ public class IotaAPITest { } @Test + @Category(IntegrationTest.class) public void shouldGetAccountData() throws ArgumentException { GetAccountDataResponse gad = iotaAPI.getAccountData(TEST_SEED1, 2, 0, true, 0, true, 0, 0, true, 0); assertThat(gad, IsNull.notNullValue()); @@ -206,6 +214,7 @@ public class IotaAPITest { } @Test + @Category(IntegrationTest.class) public void shouldGetBundle() throws ArgumentException { GetBundleResponse gbr = iotaAPI.getBundle(TEST_HASH); System.out.println(gbr); @@ -213,6 +222,7 @@ public class IotaAPITest { } @Test + @Category(IntegrationTest.class) public void shouldGetTransfers() throws ArgumentException { GetTransferResponse gtr = iotaAPI.getTransfers(TEST_SEED1, 2, 0, 0, false); assertThat(gtr.getTransfers(), IsNull.notNullValue()); @@ -239,11 +249,13 @@ public class IotaAPITest { } @Test() + @Category(IntegrationTest.class) public void shouldGetTrytes() throws ArgumentException { System.out.println(iotaAPI.getTrytes(TEST_HASH)); } @Test() + @Category(IntegrationTest.class) public void shouldBroadcastAndStore() throws ArgumentException { System.out.println(iotaAPI.broadcastAndStore(TEST_TRYTES)); } diff --git a/jota/src/test/java/jota/IotaCoreApiTest.java b/jota/src/test/java/jota/IotaCoreApiTest.java index c33487a..de4dfae 100644 --- a/jota/src/test/java/jota/IotaCoreApiTest.java +++ b/jota/src/test/java/jota/IotaCoreApiTest.java @@ -1,11 +1,13 @@ package jota; import com.google.gson.Gson; +import jota.category.IntegrationTest; import jota.dto.response.*; import jota.error.ArgumentException; import org.hamcrest.core.IsNull; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.Collections; @@ -27,6 +29,7 @@ public class IotaCoreApiTest { } @Test + @Category(IntegrationTest.class) public void shouldGetNodeInfo() { GetNodeInfoResponse nodeInfo = proxy.getNodeInfo(); System.out.println(new Gson().toJson(nodeInfo)); @@ -49,71 +52,83 @@ public class IotaCoreApiTest { } @Test + @Category(IntegrationTest.class) public void shouldGetNeighbors() { GetNeighborsResponse neighbors = proxy.getNeighbors(); assertThat(neighbors.getNeighbors(), IsNull.notNullValue()); } @Test(expected = IllegalAccessError.class) + @Category(IntegrationTest.class) public void shouldAddNeighbors() { AddNeighborsResponse res = proxy.addNeighbors("udp://8.8.8.8:14265"); assertThat(res, IsNull.notNullValue()); } @Test(expected = IllegalAccessError.class) + @Category(IntegrationTest.class) public void shouldRemoveNeighbors() { RemoveNeighborsResponse res = proxy.removeNeighbors("udp://8.8.8.8:14265"); assertThat(res, IsNull.notNullValue()); } @Test + @Category(IntegrationTest.class) public void shouldGetTips() { GetTipsResponse tips = proxy.getTips(); assertThat(tips, IsNull.notNullValue()); } @Test + @Category(IntegrationTest.class) public void shouldFindTransactionsByAddresses() throws ArgumentException { FindTransactionResponse trans = proxy.findTransactionsByAddresses(TEST_ADDRESS_WITH_CHECKSUM); assertThat(trans.getHashes(), IsNull.notNullValue()); } @Test + @Category(IntegrationTest.class) public void shouldFindTransactionsByApprovees() { FindTransactionResponse trans = proxy.findTransactionsByApprovees(TEST_HASH); assertThat(trans.getHashes(), IsNull.notNullValue()); } @Test + @Category(IntegrationTest.class) public void shouldFindTransactionsByBundles() { FindTransactionResponse trans = proxy.findTransactionsByBundles(TEST_HASH); assertThat(trans.getHashes(), IsNull.notNullValue()); } @Test + @Category(IntegrationTest.class) public void shouldFindTransactionsByDigests() { FindTransactionResponse trans = proxy.findTransactionsByDigests(TEST_HASH); assertThat(trans.getHashes(), IsNull.notNullValue()); } @Test + @Category(IntegrationTest.class) public void shouldGetTrytes() throws ArgumentException { GetTrytesResponse res = proxy.getTrytes(TEST_HASH); assertThat(res.getTrytes(), IsNull.notNullValue()); } @Test + @Category(IntegrationTest.class) public void shouldNotGetInclusionStates() throws ArgumentException { proxy.getInclusionStates(new String[]{TEST_HASH}, new String[]{"ZIJGAJ9AADLRPWNCYNNHUHRRAC9QOUDATEDQUMTNOTABUVRPTSTFQDGZKFYUUIE9ZEBIVCCXXXLKX9999"}); } @Test + @Category(IntegrationTest.class) public void shouldGetInclusionStates() throws ArgumentException { GetInclusionStateResponse res = proxy.getInclusionStates(new String[]{TEST_HASH}, new String[]{proxy.getNodeInfo().getLatestSolidSubtangleMilestone()}); assertThat(res.getStates(), IsNull.notNullValue()); } @Test // very long execution + @Category(IntegrationTest.class) public void shouldGetTransactionsToApprove() { GetTransactionsToApproveResponse res = proxy.getTransactionsToApprove(27); assertThat(res.getTrunkTransaction(), IsNull.notNullValue()); @@ -121,6 +136,7 @@ public class IotaCoreApiTest { } @Test + @Category(IntegrationTest.class) public void shouldFindTransactions() { String test = TEST_BUNDLE; FindTransactionResponse resp = proxy.findTransactions(new String[]{test}, new String[]{test}, new String[]{test}, new String[]{test}); @@ -128,6 +144,7 @@ public class IotaCoreApiTest { } @Test + @Category(IntegrationTest.class) public void shouldGetBalances() throws ArgumentException { GetBalancesResponse res = proxy.getBalances(100, Collections.singletonList(TEST_ADDRESS_WITH_CHECKSUM)); assertThat(res.getBalances(), IsNull.notNullValue()); diff --git a/jota/src/test/java/jota/IotaMultisigTest.java b/jota/src/test/java/jota/IotaMultisigTest.java index 82435ff..f12c423 100644 --- a/jota/src/test/java/jota/IotaMultisigTest.java +++ b/jota/src/test/java/jota/IotaMultisigTest.java @@ -1,5 +1,6 @@ package jota; +import jota.category.IntegrationTest; import jota.error.ArgumentException; import jota.model.Bundle; import jota.model.Transaction; @@ -10,6 +11,7 @@ import jota.utils.Multisig; import jota.utils.Signing; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.ArrayList; import java.util.List; @@ -35,6 +37,7 @@ public class IotaMultisigTest { } @Test + @Category(IntegrationTest.class) public void basicMultiSigTest() throws ArgumentException { Multisig ms = new Multisig(); diff --git a/jota/src/test/java/jota/category/IntegrationTest.java b/jota/src/test/java/jota/category/IntegrationTest.java new file mode 100644 index 0000000..76e6d6a --- /dev/null +++ b/jota/src/test/java/jota/category/IntegrationTest.java @@ -0,0 +1,4 @@ +package jota.category; + +public interface IntegrationTest { +} diff --git a/jota/src/test/java/jota/category/UnitTest.java b/jota/src/test/java/jota/category/UnitTest.java new file mode 100644 index 0000000..559d37e --- /dev/null +++ b/jota/src/test/java/jota/category/UnitTest.java @@ -0,0 +1,4 @@ +package jota.category; + +public interface UnitTest { +} diff --git a/pom.xml b/pom.xml index f0e2c15..fbba7b8 100644 --- a/pom.xml +++ b/pom.xml @@ -51,12 +51,12 @@ 1.7 1.7 UTF-8 - true 2.5.3 3.0.1 2.10.4 + 2.13 @@ -128,6 +128,21 @@ @{project.version} + + org.apache.maven.plugins + maven-surefire-plugin + ${version.maven-surefire-plugin} + + + org.apache.maven.surefire + surefire-junit47 + ${version.maven-surefire-plugin} + + + + jota.category.IntegrationTest + +