Compare commits
7 Commits
feature-te
...
feature/ci
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acca84e265 | ||
|
|
c80b649258 | ||
|
|
49de28930e | ||
|
|
ac94e042f4 | ||
|
|
f43ea41133 | ||
|
|
25d628e222 | ||
|
|
78b0aee8ab |
21
Jenkinsfile
vendored
21
Jenkinsfile
vendored
@@ -6,7 +6,7 @@ pipeline {
|
||||
|
||||
steps {
|
||||
withMaven(maven : 'maven_3_5_0') {
|
||||
sh 'mvn clean install'
|
||||
sh 'mvn clean compile'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,24 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Generate HTML report') {
|
||||
stage ('Deploy?') {
|
||||
steps {
|
||||
cucumber buildStatus: "UNSTABLE",
|
||||
fileIncludePattern: '**/cucumber.json',
|
||||
jsonReportDirectory: 'target'
|
||||
input('Do you want to deploy?')
|
||||
}
|
||||
}
|
||||
|
||||
stage ('Deployment Stage') {
|
||||
steps {
|
||||
|
||||
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'PCF_LOGIN',
|
||||
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
|
||||
|
||||
sh '/usr/local/bin/cf login -a http://api.run.pivotal.io -u $USERNAME -p $PASSWORD'
|
||||
sh '/usr/local/bin/cf push'
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
pom.xml
28
pom.xml
@@ -12,6 +12,8 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<junit.jupiter.version>5.0.0-M3</junit.jupiter.version>
|
||||
<junit.platform.version>1.0.0-M3</junit.platform.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -29,9 +31,9 @@
|
||||
<version>2.19</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-surefire-provider</artifactId>
|
||||
<version>1.0.0-M3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
@@ -39,22 +41,16 @@
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>info.cukes</groupId>
|
||||
<artifactId>cucumber-java</artifactId>
|
||||
<version>1.2.5</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.0.0-M3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>info.cukes</groupId>
|
||||
<artifactId>cucumber-junit</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-runner</artifactId>
|
||||
<version>${junit.platform.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -5,16 +5,10 @@ public class FizzBuzz {
|
||||
public String play(int number) {
|
||||
|
||||
if (number == 0) throw new IllegalArgumentException("Number must not be 0");
|
||||
|
||||
if (isMultipleOf(number, 3) && isMultipleOf(number, 5)) return "FizzBuzz";
|
||||
if (isMultipleOf(number, 3)) return "Fizz";
|
||||
if (isMultipleOf(number, 5)) return "Buzz";
|
||||
if (number % 3 == 0) return "Fizz";
|
||||
if (number % 5 == 0) return "Buzz";
|
||||
|
||||
|
||||
return String.valueOf(number);
|
||||
}
|
||||
|
||||
private boolean isMultipleOf(int number, int i) {
|
||||
return number % i == 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.techprimers.testing;
|
||||
|
||||
import cucumber.api.CucumberOptions;
|
||||
import cucumber.api.junit.Cucumber;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(Cucumber.class)
|
||||
@CucumberOptions(
|
||||
features = "src/test/resources",
|
||||
glue = "com.techprimers.testing",
|
||||
format = {"json:target/cucumber.json"}
|
||||
)
|
||||
public class CucumberTest {
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.techprimers.testing;
|
||||
|
||||
import cucumber.api.java.en.Given;
|
||||
import cucumber.api.java.en.Then;
|
||||
import cucumber.api.java.en.When;
|
||||
import org.junit.Assert;
|
||||
public class FizzBuzzStepdefs {
|
||||
|
||||
FizzBuzz fizzBuzz;
|
||||
String result;
|
||||
|
||||
@Given("^Create a FizzBuzz game play$")
|
||||
public void createAFizzBuzzGamePlay() throws Throwable {
|
||||
fizzBuzz = new FizzBuzz();
|
||||
}
|
||||
|
||||
@When("^I play with number (\\d+)$")
|
||||
public void iPlayWithNumber(int number) throws Throwable {
|
||||
result = fizzBuzz.play(number);
|
||||
}
|
||||
|
||||
@Then("^The result is \"([^\"]*)\"$")
|
||||
public void theResultIs(String resultString) throws Throwable {
|
||||
Assert.assertEquals(result, resultString);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +1,46 @@
|
||||
package com.techprimers.testing;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
public class FizzBuzzTest {
|
||||
class FizzBuzzTest {
|
||||
|
||||
public FizzBuzz fB;
|
||||
|
||||
// @
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
fB = new FizzBuzz();
|
||||
}
|
||||
|
||||
// @DisplayName("Play FizzBuzz with number = 1")
|
||||
@DisplayName("Play FizzBuzz with number = 1")
|
||||
@Test
|
||||
public void testNumber() {
|
||||
String fizzBuzz = fB.play(1);
|
||||
Assert.assertEquals(fizzBuzz, "1");
|
||||
Assertions.assertEquals(fizzBuzz, "1");
|
||||
}
|
||||
|
||||
// @DisplayName("Play FizzBuzz with number = 3")
|
||||
@DisplayName("Play FizzBuzz with number = 3")
|
||||
@Test
|
||||
public void testFizz() {
|
||||
String fizzBuzz = fB.play(3);
|
||||
Assert.assertEquals(fizzBuzz, "Fizz");
|
||||
Assertions.assertEquals(fizzBuzz, "Fizz");
|
||||
}
|
||||
|
||||
// @DisplayName("Play FizzBuzz with number = 5")
|
||||
@DisplayName("Play FizzBuzz with number = 5")
|
||||
@Test
|
||||
public void testBuzz() {
|
||||
String fizzBuzz = fB.play(5);
|
||||
Assert.assertEquals(fizzBuzz, "Buzz");
|
||||
Assertions.assertEquals(fizzBuzz, "Buzz");
|
||||
}
|
||||
|
||||
// @DisplayName("Don't Play FizzBuzz with number = 0")
|
||||
// @Test
|
||||
// public void testZero() {
|
||||
//
|
||||
// Assert.assertThat(IllegalArgumentException.class,
|
||||
// () -> fB.play(0));
|
||||
// }
|
||||
@DisplayName("Don't Play FizzBuzz with number = 0")
|
||||
@Test
|
||||
public void testZero() {
|
||||
|
||||
// @AfterEach
|
||||
@After
|
||||
Assertions.assertThrows(IllegalArgumentException.class,
|
||||
() -> fB.play(0));
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
fB = null;
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
Feature: FizzBuzz Game play
|
||||
|
||||
Scenario: Play FizzBuzz to get Fizz
|
||||
Given Create a FizzBuzz game play
|
||||
When I play with number 3
|
||||
Then The result is "Fizz"
|
||||
|
||||
Scenario: Play FizzBuzz to get Buzz
|
||||
Given Create a FizzBuzz game play
|
||||
When I play with number 5
|
||||
Then The result is "Buzz"
|
||||
|
||||
Scenario: Play FizzBuzz to get FizzBuzz
|
||||
Given Create a FizzBuzz game play
|
||||
When I play with number 15
|
||||
Then The result is "FizzBuzz"
|
||||
Reference in New Issue
Block a user