diff --git a/java-repo-tools/.travis.yml b/java-repo-tools/.travis.yml index bb7197c540d..d5659c59ce8 100644 --- a/java-repo-tools/.travis.yml +++ b/java-repo-tools/.travis.yml @@ -13,11 +13,11 @@ # limitations under the License. language: java jdk: - - oraclejdk7 - - oraclejdk8 +- oraclejdk7 +- oraclejdk8 script: mvn verify after_success: - - mvn clean cobertura:cobertura coveralls:report +- bash <(curl -s https://codecov.io/bash) branches: only: - master diff --git a/java-repo-tools/README.md b/java-repo-tools/README.md index 41f39c7a02b..0c172c9c051 100644 --- a/java-repo-tools/README.md +++ b/java-repo-tools/README.md @@ -2,6 +2,8 @@ [![Build Status](https://travis-ci.org/GoogleCloudPlatform/java-repo-tools.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/java-repo-tools) +[![Coverage +Status](https://codecov.io/gh/GoogleCloudPlatform/java-repo-tools/branch/master/graph/badge.svg)](https://codecov.io/gh/GoogleCloudPlatform/java-repo-tools) This is a collection of common tools used to maintain and test Java repositories in the [GoogleCloudPlaftorm](https://github.com/GoogleCloudPlatform) diff --git a/java-repo-tools/codecov.yml b/java-repo-tools/codecov.yml new file mode 100644 index 00000000000..f5c84448f07 --- /dev/null +++ b/java-repo-tools/codecov.yml @@ -0,0 +1,18 @@ +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +codecov: + branch: master +comment: + branches: + - master diff --git a/java-repo-tools/pom.xml b/java-repo-tools/pom.xml index 90560a99bac..48490d39f6b 100644 --- a/java-repo-tools/pom.xml +++ b/java-repo-tools/pom.xml @@ -75,25 +75,30 @@ limitations under the License. check - - org.jacoco - jacoco-maven-plugin - 0.7.6.201602180812 - - - - prepare-agent - - - - report - test - - report - - - - + + org.codehaus.mojo + versions-maven-plugin + 2.2 + + + org.jacoco + jacoco-maven-plugin + 0.7.6.201602180812 + + + + prepare-agent + + + + report + test + + report + + + + diff --git a/java-repo-tools/test/pom.xml b/java-repo-tools/test/pom.xml index 96f42c5f06a..0bde62cec8e 100644 --- a/java-repo-tools/test/pom.xml +++ b/java-repo-tools/test/pom.xml @@ -41,7 +41,7 @@ limitations under the License. com.google.truth truth - 0.27 + 0.28 test diff --git a/java-repo-tools/test/src/main/java/com/google/cloud/samples/test/App.java b/java-repo-tools/test/src/main/java/com/google/cloud/samples/test/App.java index 244b1507594..a2e47132975 100644 --- a/java-repo-tools/test/src/main/java/com/google/cloud/samples/test/App.java +++ b/java-repo-tools/test/src/main/java/com/google/cloud/samples/test/App.java @@ -20,11 +20,12 @@ * A hello world app to test the parent pom.xml. */ public class App { - public static String greeting() { + public String greeting() { return "Hello World!"; } public static void main(String[] args) { - System.out.println(App.greeting()); + App app = new App(); + System.out.println(app.greeting()); } } diff --git a/java-repo-tools/test/src/test/java/com/google/cloud/samples/test/AppTest.java b/java-repo-tools/test/src/test/java/com/google/cloud/samples/test/AppTest.java index ab7f5095aae..3bdb86fa09a 100644 --- a/java-repo-tools/test/src/test/java/com/google/cloud/samples/test/AppTest.java +++ b/java-repo-tools/test/src/test/java/com/google/cloud/samples/test/AppTest.java @@ -22,12 +22,21 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + /** * Unit tests for {@link App}. */ @RunWith(JUnit4.class) public class AppTest { - @Test public void greeting_returnsHelloWorld() { - assertThat(App.greeting()).named("greeting").isEqualTo("Hello World!"); + @Test public void main_printsHelloWorld() { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + System.setOut(new PrintStream(out)); + + App.main(new String[0]); + + String greeting = out.toString(); + assertThat(greeting).named("greeting").contains("Hello World!"); } }