Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hollie #8

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
language: java
# the following will skip the installation of dependencies.
install: true

script: ./gradlew build
# the following forces the use of JDK 8
# matrix:
# include:
# - jdk: oraclejdk8

script:
- gradle clean build
- gradle dist --rerun-tasks
# - gradle distSetup --rerun-tasks
# - gradle zipDist --rerun-tasks
# - gradle zipTest --rerun-tasks

before_deploy:
- git config --global user.email "[email protected]"
- git config --global user.name "Travis CI"
- export GIT_TAG=$TRAVIS_BRANCH.$TRAVIS_BUILD_NUMBER
- git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
- git push -q https://[email protected]/drlehr/java-hello-world-with-gradle --tags
- ls -R

deploy:
skip_cleanup: true
provider: releases
api_key:
secure: $GITPERM

file:
- "README.md"
- "build.gradle"
- ".travis.yml"

on:
tags: false
all_branches: true
Collapse


script: ./gradlew build
deploy:
provider: releases
api_key:
Expand Down
57 changes: 47 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* user guide available at https://docs.gradle.org/2.8/userguide/tutorial_java_projects.html
*/


/*
// Apply the java plugin to add support for Java
apply plugin: 'java'
Expand All @@ -28,37 +29,73 @@ dependencies {
}
*/


apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'

mainClassName = 'hello.HelloWorld'

// tag::repositories[]
repositories {
mavenCentral()
}
// end::repositories[]

// tag::jar[]
jar {
baseName = 'jb-hello-world'
version = '0.1.0'
}
// end::jar[]

// tag::dependencies[]
sourceCompatibility = 1.7
targetCompatibility = 1.7

sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile "joda-time:joda-time:2.2"
testCompile "junit:junit:4.12"
testCompile "org.junit.jupiter:junit-jupiter-api:5.0.1"
// the following is a work around to fix the warning:
// warning: unknown enum constant Status.STABLE
testCompileOnly "org.apiguardian:apiguardian-api:1.0.0"
}
// end::dependencies[]

task dist {
description "Generate the dist(s) into the dist folder."
}
task distSetup {
description "Generate the dist folder."
delete "${projectDir}/dist"
copy {
from "${buildDir}/libs"
into "${projectDir}/dist/main"
}
copy {
from "${projectDir}/build/classes/test/Output"
into "${projectDir}/dist/test"
}
}
task zipDist(type: Zip, dependsOn: distSetup) {
from "${projectDir}/dist/main"
from "${projectDir}/Readme.md"
destinationDir = file("${projectDir}/dist")
version = "${version}"
appendix = "Main"
doLast {
println "Created ${zipDist.archiveName}"
}
}
task zipTest(type: Zip, dependsOn: distSetup) {
from "${projectDir}/dist/test"
from "${projectDir}/Readme.md"
destinationDir = file("${projectDir}/dist")
version = "${version}"
appendix = "Test Output"
doLast{
println "Created ${zipTest.archiveName}"
}
}
distSetup.dependsOn(build)
dist.dependsOn(zipDist)
dist.dependsOn(zipTest)
// tag::wrapper[]
task wrapper(type: Wrapper) {
gradleVersion = '3.5'
gradleVersion = '4.9'
}
// end::wrapper[]
49 changes: 32 additions & 17 deletions src/test/java/hello/TestGreeter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,58 @@
import org.junit.Before;
import org.junit.Test;


public class TestGreeter {
private Greeter g;
@Before
public void setUp() throws Exception
{
public void setUp() throws Exception {
g = new Greeter();
}


@Test
public void testGreeterEmpty()
{
public void testGreeterEmpty() {
assertEquals(g.getName(),"");
assertEquals(g.sayHello(),"Hello!");
}

@Test
public void testGreeter()
{
public void testGreeter() {
g.setName("World");
assertEquals(g.getName(),"World");
assertEquals(g.sayHello(),"Hello World!");
}

@Test

@Test
public void newtestHBWGreeterPass() {

g.setName("Hollie, YOU ARE AMAZING");

assertEquals(g.getName(),"Hollie, YOU ARE AMAZING");

assertEquals(g.sayHello(),"Hello Hollie, YOU ARE AMAZING!");

}

@Test
public void newtestHBWGreeterPass2(){

g.setName("Hollie");

assertEquals(g.getName(),"Hollie");

assertEquals(g.sayHello(),"Hello Hollie!");

}

@Test
public void newtestWMGreeterPass() {
g.setName("Boris");
assertEquals(g.getName(),"Boris");
assertEquals(g.sayHello(),"Hello Boris!");
}
/*
@Test
public void newtestWMGreeterFail() {
g.setName("Sandvich");
assertEquals(g.getName(),"Boris");
assertEquals(g.sayHello(),"Hello Boris!");
}
*/

}