13 Commits

Author SHA1 Message Date
Ajay Kumar S
3fe0f99d28 Update FizzBuzz.feature 2019-07-19 22:40:55 +05:30
TechPrimers
5a33fdc557 add new branch for testing 2018-10-29 23:47:39 +05:30
TechPrimers
1f487f5f1e add new branch for testing 2018-10-29 23:42:48 +05:30
TechPrimers
8404775d1f add new branch for testing 2018-10-29 23:40:30 +05:30
TechPrimers
6babdf33cb add new branch for testing 2018-10-29 23:33:32 +05:30
TechPrimers
f842d55ed2 add new branch for aws deploy testing 2018-06-10 18:30:05 +05:30
TechPrimers
f08e6e83f2 add new branch for aws deploy testing 2018-06-10 18:29:29 +05:30
TechPrimers
0205396449 add new branch for aws deploy testing 2018-06-10 18:26:57 +05:30
TechPrimers
9037623604 add new branch for aws deploy testing 2018-06-10 18:18:27 +05:30
TechPrimers
a1ce73f535 add new branch for aws deploy testing 2018-06-10 18:06:28 +05:30
TechPrimers
ec8b84b630 add new branch for aws deploy testing 2018-06-10 17:58:02 +05:30
TechPrimers
aa6be34cd7 add new branch for aws deploy testing 2018-06-10 17:38:52 +05:30
TechPrimers
9dde1ef038 add new branch for aws deploy testing 2018-06-10 12:56:42 +05:30
7 changed files with 108 additions and 37 deletions

14
Jenkinsfile vendored
View File

@@ -6,7 +6,7 @@ pipeline {
steps { steps {
withMaven(maven : 'maven_3_5_0') { withMaven(maven : 'maven_3_5_0') {
sh 'mvn clean compile' sh 'mvn clean install'
} }
} }
} }
@@ -20,13 +20,13 @@ pipeline {
} }
} }
stage('Generate HTML report') {
stage ('Deployment Stage') {
steps { steps {
withMaven(maven : 'maven_3_5_0') { cucumber buildStatus: "UNSTABLE",
sh 'mvn deploy' fileIncludePattern: '**/cucumber.json',
} jsonReportDirectory: 'target'
} }
} }
} }
} }

28
pom.xml
View File

@@ -12,8 +12,6 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version> <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> </properties>
<build> <build>
@@ -31,9 +29,9 @@
<version>2.19</version> <version>2.19</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.junit.platform</groupId> <groupId>junit</groupId>
<artifactId>junit-platform-surefire-provider</artifactId> <artifactId>junit</artifactId>
<version>1.0.0-M3</version> <version>4.12</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
@@ -41,16 +39,22 @@
</build> </build>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>info.cukes</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>cucumber-java</artifactId>
<version>5.0.0-M3</version> <version>1.2.5</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.platform</groupId> <groupId>info.cukes</groupId>
<artifactId>junit-platform-runner</artifactId> <artifactId>cucumber-junit</artifactId>
<version>${junit.platform.version}</version> <version>1.2.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -5,10 +5,16 @@ public class FizzBuzz {
public String play(int number) { public String play(int number) {
if (number == 0) throw new IllegalArgumentException("Number must not be 0"); if (number == 0) throw new IllegalArgumentException("Number must not be 0");
if (number % 3 == 0) return "Fizz";
if (number % 5 == 0) return "Buzz"; if (isMultipleOf(number, 3) && isMultipleOf(number, 5)) return "FizzBuzz";
if (isMultipleOf(number, 3)) return "Fizz";
if (isMultipleOf(number, 5)) return "Buzz";
return String.valueOf(number); return String.valueOf(number);
} }
private boolean isMultipleOf(int number, int i) {
return number % i == 0;
}
} }

View File

@@ -0,0 +1,14 @@
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 {
}

View File

@@ -0,0 +1,26 @@
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);
}
}

View File

@@ -1,46 +1,51 @@
package com.techprimers.testing; package com.techprimers.testing;
import org.junit.jupiter.api.*; import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
class FizzBuzzTest { public class FizzBuzzTest {
public FizzBuzz fB; public FizzBuzz fB;
@BeforeEach // @
@Before
public void setUp() { public void setUp() {
fB = new FizzBuzz(); fB = new FizzBuzz();
} }
@DisplayName("Play FizzBuzz with number = 1") // @DisplayName("Play FizzBuzz with number = 1")
@Test @Test
public void testNumber() { public void testNumber() {
String fizzBuzz = fB.play(1); String fizzBuzz = fB.play(1);
Assertions.assertEquals(fizzBuzz, "1"); Assert.assertEquals(fizzBuzz, "1");
} }
@DisplayName("Play FizzBuzz with number = 3") // @DisplayName("Play FizzBuzz with number = 3")
@Test @Test
public void testFizz() { public void testFizz() {
String fizzBuzz = fB.play(3); String fizzBuzz = fB.play(3);
Assertions.assertEquals(fizzBuzz, "Fizz"); Assert.assertEquals(fizzBuzz, "Fizz");
} }
@DisplayName("Play FizzBuzz with number = 5") // @DisplayName("Play FizzBuzz with number = 5")
@Test @Test
public void testBuzz() { public void testBuzz() {
String fizzBuzz = fB.play(5); String fizzBuzz = fB.play(5);
Assertions.assertEquals(fizzBuzz, "Buzz"); Assert.assertEquals(fizzBuzz, "Buzz");
} }
@DisplayName("Don't Play FizzBuzz with number = 0") // @DisplayName("Don't Play FizzBuzz with number = 0")
@Test // @Test
public void testZero() { // public void testZero() {
//
// Assert.assertThat(IllegalArgumentException.class,
// () -> fB.play(0));
// }
Assertions.assertThrows(IllegalArgumentException.class, // @AfterEach
() -> fB.play(0)); @After
}
@AfterEach
public void tearDown() { public void tearDown() {
fB = null; fB = null;
} }

View File

@@ -0,0 +1,16 @@
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"