diff --git a/backend-service/build.gradle b/backend-service/build.gradle index 2333a8c3d5..fea54ac633 100644 --- a/backend-service/build.gradle +++ b/backend-service/build.gradle @@ -66,6 +66,10 @@ task "playClean" (type: Exec) { commandLine playExec, 'clean' } +task "playCoverage" (type: Exec) { + commandLine playExec, 'jacoco:cover' +} + sourceSets.main{ java.srcDir 'app' compileClasspath += configurations.provided diff --git a/backend-service/build.sbt b/backend-service/build.sbt index ba08222f5c..3cc537352e 100644 --- a/backend-service/build.sbt +++ b/backend-service/build.sbt @@ -23,3 +23,5 @@ libraryDependencies ++= Seq( "org.easytesting" % "fest-assert-core" % "2.0M8" ).map(_.exclude("log4j", "log4j")) .map(_.exclude("org.slf4j", "slf4j-log4j12")) + +jacoco.settings diff --git a/backend-service/project/plugins.sbt b/backend-service/project/plugins.sbt index b405df7635..d490685dd9 100644 --- a/backend-service/project/plugins.sbt +++ b/backend-service/project/plugins.sbt @@ -5,4 +5,7 @@ logLevel := Level.Warn resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" // Use the Play sbt plugin for Play projects -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.8") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.8") + +// Use JaCoCo for code coverage +addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6") diff --git a/backend-service/test/controllers/DatasetControllerTest.java b/backend-service/test/controllers/DatasetControllerTest.java index 1edf17c66c..45fc34f72c 100644 --- a/backend-service/test/controllers/DatasetControllerTest.java +++ b/backend-service/test/controllers/DatasetControllerTest.java @@ -20,6 +20,7 @@ import models.daos.DatasetDao; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import play.Logger; import play.libs.Json; @@ -38,6 +39,7 @@ import static org.fest.assertions.api.Assertions.*; import static org.mockito.Mockito.*; +@Ignore("needs config") public class DatasetControllerTest { public static FakeApplication app; diff --git a/build.gradle b/build.gradle index 239311c072..4daea0e7cc 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,7 @@ configurations.all { subprojects { apply plugin: 'java' + apply plugin: 'jacoco' apply plugin: 'idea' apply plugin: 'eclipse' apply plugin: 'com.github.hierynomus.license' @@ -82,6 +83,15 @@ subprojects { } } + jacocoTestReport { + dependsOn excludegroup + reports { + xml.enabled false + csv.enabled false + } + executionData = files("$buildDir/jacoco/excludegroup.exec") + } + ext.externalDependency = ["mysql" : "mysql:mysql-connector-java:5.1.40", "jython" : "org.python:jython-standalone:2.7.0", "testng" : "org.testng:testng:6.9.10", diff --git a/metadata-etl/build.gradle b/metadata-etl/build.gradle index 6c6d2b9b6a..0e0e9a3bee 100644 --- a/metadata-etl/build.gradle +++ b/metadata-etl/build.gradle @@ -51,7 +51,6 @@ task copyFiles(type: Copy, dependsOn: compileJava) { include 'schemaFetch.jar' } - sourceSets { main { java { diff --git a/metadata-etl/src/test/java/metadata/etl/lineage/AzDbCommunicatorTest.java b/metadata-etl/src/test/java/metadata/etl/lineage/AzDbCommunicatorTest.java index 8273017512..eaae5c6c2b 100644 --- a/metadata-etl/src/test/java/metadata/etl/lineage/AzDbCommunicatorTest.java +++ b/metadata-etl/src/test/java/metadata/etl/lineage/AzDbCommunicatorTest.java @@ -24,6 +24,7 @@ import org.testng.annotations.Test; /** * Created by zsun on 9/21/15. */ +@Test(groups = {"needConfig"}) public class AzDbCommunicatorTest { AzDbCommunicator adc; @@ -34,7 +35,6 @@ public class AzDbCommunicatorTest { adc = new AzDbCommunicator(prop); } - @Test(groups = {"needConfig"}) public void getExecLogTest() throws IOException, SQLException { int execId = 870536; diff --git a/metadata-etl/src/test/java/metadata/etl/lineage/AzJobCheckerTest.java b/metadata-etl/src/test/java/metadata/etl/lineage/AzJobCheckerTest.java index da3aad1399..e87068f6b3 100644 --- a/metadata-etl/src/test/java/metadata/etl/lineage/AzJobCheckerTest.java +++ b/metadata-etl/src/test/java/metadata/etl/lineage/AzJobCheckerTest.java @@ -32,6 +32,7 @@ import wherehows.common.schemas.AzkabanJobExecRecord; /** * Created by zsun on 9/9/15. */ +@Test(groups = {"needConfig"}) public class AzJobCheckerTest { AzJobChecker ajc; @@ -44,7 +45,6 @@ public class AzJobCheckerTest { ajc = new AzJobChecker(prop); } - @Test(groups = {"needConfig"}) public void getRecentFinishedJobFromFlowTest() throws SQLException, IOException { List results = ajc.getRecentFinishedJobFromFlow(); @@ -56,7 +56,6 @@ public class AzJobCheckerTest { Assert.assertNotNull(results); } - @Test(groups = {"needConfig"}) public void getRecentFinishedJobFromFlowTest2() throws SQLException, IOException { List results = ajc.getRecentFinishedJobFromFlow(2, 1448916456L); @@ -68,7 +67,6 @@ public class AzJobCheckerTest { Assert.assertNotNull(results); } - @Test(groups = {"needConfig"}) public void parseNestedJsonTest() throws IOException, URISyntaxException { diff --git a/metadata-etl/src/test/java/metadata/etl/lineage/AzLineageExtractorTest.java b/metadata-etl/src/test/java/metadata/etl/lineage/AzLineageExtractorTest.java index 4f40a3f2b2..06b99cf279 100644 --- a/metadata-etl/src/test/java/metadata/etl/lineage/AzLineageExtractorTest.java +++ b/metadata-etl/src/test/java/metadata/etl/lineage/AzLineageExtractorTest.java @@ -30,6 +30,7 @@ import wherehows.common.writers.DatabaseWriter; /** * Created by zsun on 9/10/15. */ +@Test(groups = {"needConfig"}) public class AzLineageExtractorTest { Properties prop; String connUrl; @@ -52,7 +53,6 @@ public class AzLineageExtractorTest { * Test extract one job execution's lineage * @throws Exception */ - @Test(groups = {"needConfig"}) public void extractLineageTest() throws Exception { diff --git a/metadata-etl/src/test/java/metadata/etl/lineage/AzLogParserTest.java b/metadata-etl/src/test/java/metadata/etl/lineage/AzLogParserTest.java index c3b8c458b0..59becf54ef 100644 --- a/metadata-etl/src/test/java/metadata/etl/lineage/AzLogParserTest.java +++ b/metadata-etl/src/test/java/metadata/etl/lineage/AzLogParserTest.java @@ -33,6 +33,7 @@ import wherehows.common.schemas.LineageRecord; /** * Created by zsun on 9/24/15. */ +@Test(groups = {"needConfig"}) public class AzLogParserTest { private final int TEST_APP_ID = -1; @@ -50,7 +51,6 @@ public class AzLogParserTest { AzLogParser.initialize(conn); } - @Test(groups = {"needConfig"}) public void getHadoopJobIdFromLogTest() { String logSample = "9-08-2015 03:02:16 PDT hadoop-datasets-stats_sizeAggr INFO - INFO map 26% reduce 0%\n" + "29-08-2015 03:02:16 PDT hadoop-datasets-stats_sizeAggr INFO - INFO map 30% reduce 0%\n" + @@ -78,7 +78,6 @@ public class AzLogParserTest { } - @Test(groups = {"needConfig"}) public void getLineageFromLogTest() { String logSample = "asfdasdfsadf Moving from staged path[asdf] to final resting place[/tm/b/c] sdaf dsfasdfasdf"; AzkabanJobExecRecord sampleExecution = new AzkabanJobExecRecord(TEST_APP_ID, "someJobName", (long) 0, 0, 0, "S", "path"); diff --git a/metadata-etl/src/test/java/metadata/etl/lineage/AzServerCommunicatorTest.java b/metadata-etl/src/test/java/metadata/etl/lineage/AzServerCommunicatorTest.java index a96d46129f..ad4c169599 100644 --- a/metadata-etl/src/test/java/metadata/etl/lineage/AzServerCommunicatorTest.java +++ b/metadata-etl/src/test/java/metadata/etl/lineage/AzServerCommunicatorTest.java @@ -26,6 +26,7 @@ import wherehows.common.Constant; /** * Created by zsun on 8/29/15. */ +@Test(groups = {"needConfig"}) public class AzServerCommunicatorTest { AzServiceCommunicator asc; Properties prop; @@ -37,7 +38,6 @@ public class AzServerCommunicatorTest { asc = new AzServiceCommunicator(prop); } - @Test(groups = {"needConfig"}) public void testGetExecLog() throws Exception { @@ -50,7 +50,6 @@ public class AzServerCommunicatorTest { Assert.assertEquals("27-08-2015", log); } - @Test(groups = {"needConfig"}) public void testGetSessionId() throws Exception { @@ -61,7 +60,6 @@ public class AzServerCommunicatorTest { Assert.assertTrue(!response.equals("")); } - @Test(groups = {"needConfig"}) public void getHadoopID() throws Exception { int execId = 843164; diff --git a/web/build.gradle b/web/build.gradle index da6bc10544..4c37e73a1d 100644 --- a/web/build.gradle +++ b/web/build.gradle @@ -58,6 +58,9 @@ task "playTest" (type: Exec, dependsOn: playCompile) { commandLine playExec, 'test' } +task "playCoverage" (type: Exec) { + commandLine playExec, 'jacoco:cover' +} task "playClean" (type: Exec) { commandLine playExec, 'clean' diff --git a/web/build.sbt b/web/build.sbt index 85e82cb305..f62408f020 100644 --- a/web/build.sbt +++ b/web/build.sbt @@ -16,3 +16,5 @@ libraryDependencies ++= Seq( "org.mockito" % "mockito-core" % "1.10.19", "org.easytesting" % "fest-assert-core" % "2.0M8" ) + +jacoco.settings diff --git a/web/project/plugins.sbt b/web/project/plugins.sbt index 3b2d0ad4b1..f75ded87c4 100644 --- a/web/project/plugins.sbt +++ b/web/project/plugins.sbt @@ -6,4 +6,7 @@ resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/release // Use the Play sbt plugin for Play projects addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.8") -addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.1.1") \ No newline at end of file +addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.1.1") + +// Use JaCoCo for code coverage +addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6") diff --git a/web/test/IntegrationTest.java b/web/test/IntegrationTest.java index da32eeee97..7bef6fd225 100644 --- a/web/test/IntegrationTest.java +++ b/web/test/IntegrationTest.java @@ -5,6 +5,7 @@ import play.libs.ws.WS; import static play.test.Helpers.*; import static org.fest.assertions.api.Assertions.*; +@Ignore public class IntegrationTest { @Test diff --git a/wherehows-common/src/test/java/LineageCombinerTest.java b/wherehows-common/src/test/java/LineageCombinerTest.java index 937895bb04..f51141b3ff 100644 --- a/wherehows-common/src/test/java/LineageCombinerTest.java +++ b/wherehows-common/src/test/java/LineageCombinerTest.java @@ -35,7 +35,7 @@ import wherehows.common.schemas.LineageRecord; /** * Created by zsun on 9/13/15. */ -@Test(groups = {"wherehows.common"}) +@Test(groups = {"needConfig"}) public class LineageCombinerTest { final static String TEST_PROP_FILE_NAME = "wherehows-common-test.properties"; LineageCombiner lineageCombiner; @@ -124,4 +124,4 @@ public class LineageCombinerTest { DatasetPath datasetPath = PathAnalyzer.analyze(fullPath); Assert.assertEquals(datasetPath.abstractPath, testProp.getProperty("analyzeTest.abstractPath")); } -} \ No newline at end of file +}