From bae562097e7d93edb5e5e17c1623eb824bbd6ef3 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Wed, 22 Jun 2016 13:24:44 -0700 Subject: [PATCH 1/6] Switch to codecov.io for coverage measurements. --- .travis.yml | 6 +++--- README.md | 2 ++ codecov.yml | 18 ++++++++++++++++++ pom.xml | 38 +++++++++++++++++++------------------- 4 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 codecov.yml diff --git a/.travis.yml b/.travis.yml index bb7197c540d..d5659c59ce8 100644 --- a/.travis.yml +++ b/.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/README.md b/README.md index 41f39c7a02b..0c172c9c051 100644 --- a/README.md +++ b/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/codecov.yml b/codecov.yml new file mode 100644 index 00000000000..f5c84448f07 --- /dev/null +++ b/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/pom.xml b/pom.xml index 90560a99bac..b97efbcd2b6 100644 --- a/pom.xml +++ b/pom.xml @@ -75,25 +75,25 @@ limitations under the License. check - - org.jacoco - jacoco-maven-plugin - 0.7.6.201602180812 - - - - prepare-agent - - - - report - test - - report - - - - + + org.jacoco + jacoco-maven-plugin + 0.7.6.201602180812 + + + + prepare-agent + + + + report + test + + report + + + + From 5076e173dfc15756935d0c3a45cbc66d5df49d9e Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Wed, 22 Jun 2016 14:00:00 -0700 Subject: [PATCH 2/6] Add versions plugin. This will allow for automatic dependencies and plugins updates. http://www.mojohaus.org/versions-maven-plugin/examples/advancing-dependency-versions.html --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index b97efbcd2b6..48490d39f6b 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,11 @@ limitations under the License. check + + org.codehaus.mojo + versions-maven-plugin + 2.2 + org.jacoco jacoco-maven-plugin From ea8a4a292216881691e2fae68a66dafca35bcc22 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Wed, 22 Jun 2016 16:29:15 -0700 Subject: [PATCH 3/6] Auto-update dependencies. --- test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pom.xml b/test/pom.xml index 96f42c5f06a..0bde62cec8e 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -41,7 +41,7 @@ limitations under the License. com.google.truth truth - 0.27 + 0.28 test From dfdedea3f177e4f0cd01767c884b5af76b521616 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Wed, 22 Jun 2016 16:43:47 -0700 Subject: [PATCH 4/6] Revert "Auto-update dependencies." --- test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pom.xml b/test/pom.xml index 0bde62cec8e..96f42c5f06a 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -41,7 +41,7 @@ limitations under the License. com.google.truth truth - 0.28 + 0.27 test From e0903a80149405e904689df9b07b391ba5c29eb8 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Tue, 28 Jun 2016 15:47:32 +0000 Subject: [PATCH 5/6] Auto-update dependencies. --- test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pom.xml b/test/pom.xml index 96f42c5f06a..0bde62cec8e 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -41,7 +41,7 @@ limitations under the License. com.google.truth truth - 0.27 + 0.28 test From f95f02e50bce86d47980314046d0b0c39f337513 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Tue, 28 Jun 2016 09:17:23 -0700 Subject: [PATCH 6/6] Improve code coverage. It's embarrassing having only 25% code coverage with literally just Hello World. This should bump it up by subbing out stdout. See: http://stackoverflow.com/a/2169336/101923 --- .../java/com/google/cloud/samples/test/App.java | 5 +++-- .../java/com/google/cloud/samples/test/AppTest.java | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/src/main/java/com/google/cloud/samples/test/App.java b/test/src/main/java/com/google/cloud/samples/test/App.java index 244b1507594..a2e47132975 100644 --- a/test/src/main/java/com/google/cloud/samples/test/App.java +++ b/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/test/src/test/java/com/google/cloud/samples/test/AppTest.java b/test/src/test/java/com/google/cloud/samples/test/AppTest.java index ab7f5095aae..3bdb86fa09a 100644 --- a/test/src/test/java/com/google/cloud/samples/test/AppTest.java +++ b/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!"); } }