Compare commits
13 Commits
feature-1
...
feature-te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fe0f99d28 | ||
|
|
5a33fdc557 | ||
|
|
1f487f5f1e | ||
|
|
8404775d1f | ||
|
|
6babdf33cb | ||
|
|
f842d55ed2 | ||
|
|
f08e6e83f2 | ||
|
|
0205396449 | ||
|
|
9037623604 | ||
|
|
a1ce73f535 | ||
|
|
ec8b84b630 | ||
|
|
aa6be34cd7 | ||
|
|
9dde1ef038 |
148
.gitignore
vendored
148
.gitignore
vendored
@@ -1,149 +1,3 @@
|
|||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
target
|
target
|
||||||
|
|
||||||
|
|
||||||
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,maven,java,jetbrains+all
|
|
||||||
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,maven,java,jetbrains+all
|
|
||||||
|
|
||||||
### Java ###
|
|
||||||
# Compiled class file
|
|
||||||
*.class
|
|
||||||
|
|
||||||
# Log file
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# BlueJ files
|
|
||||||
*.ctxt
|
|
||||||
|
|
||||||
# Mobile Tools for Java (J2ME)
|
|
||||||
.mtj.tmp/
|
|
||||||
|
|
||||||
# Package Files #
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.nar
|
|
||||||
*.ear
|
|
||||||
*.zip
|
|
||||||
*.tar.gz
|
|
||||||
*.rar
|
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
|
||||||
hs_err_pid*
|
|
||||||
|
|
||||||
### JetBrains+all ###
|
|
||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
|
||||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
|
||||||
|
|
||||||
# User-specific stuff
|
|
||||||
.idea/**/workspace.xml
|
|
||||||
.idea/**/tasks.xml
|
|
||||||
.idea/**/usage.statistics.xml
|
|
||||||
.idea/**/dictionaries
|
|
||||||
.idea/**/shelf
|
|
||||||
|
|
||||||
# Generated files
|
|
||||||
.idea/**/contentModel.xml
|
|
||||||
|
|
||||||
# Sensitive or high-churn files
|
|
||||||
.idea/**/dataSources/
|
|
||||||
.idea/**/dataSources.ids
|
|
||||||
.idea/**/dataSources.local.xml
|
|
||||||
.idea/**/sqlDataSources.xml
|
|
||||||
.idea/**/dynamic.xml
|
|
||||||
.idea/**/uiDesigner.xml
|
|
||||||
.idea/**/dbnavigator.xml
|
|
||||||
|
|
||||||
# Gradle
|
|
||||||
.idea/**/gradle.xml
|
|
||||||
.idea/**/libraries
|
|
||||||
|
|
||||||
# Gradle and Maven with auto-import
|
|
||||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
|
||||||
# since they will be recreated, and may cause churn. Uncomment if using
|
|
||||||
# auto-import.
|
|
||||||
# .idea/artifacts
|
|
||||||
# .idea/compiler.xml
|
|
||||||
# .idea/jarRepositories.xml
|
|
||||||
# .idea/modules.xml
|
|
||||||
# .idea/*.iml
|
|
||||||
# .idea/modules
|
|
||||||
# *.iml
|
|
||||||
# *.ipr
|
|
||||||
|
|
||||||
# CMake
|
|
||||||
cmake-build-*/
|
|
||||||
|
|
||||||
# Mongo Explorer plugin
|
|
||||||
.idea/**/mongoSettings.xml
|
|
||||||
|
|
||||||
# File-based project format
|
|
||||||
*.iws
|
|
||||||
|
|
||||||
# IntelliJ
|
|
||||||
out/
|
|
||||||
|
|
||||||
# mpeltonen/sbt-idea plugin
|
|
||||||
.idea_modules/
|
|
||||||
|
|
||||||
# JIRA plugin
|
|
||||||
atlassian-ide-plugin.xml
|
|
||||||
|
|
||||||
# Cursive Clojure plugin
|
|
||||||
.idea/replstate.xml
|
|
||||||
|
|
||||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
|
||||||
com_crashlytics_export_strings.xml
|
|
||||||
crashlytics.properties
|
|
||||||
crashlytics-build.properties
|
|
||||||
fabric.properties
|
|
||||||
|
|
||||||
# Editor-based Rest Client
|
|
||||||
.idea/httpRequests
|
|
||||||
|
|
||||||
# Android studio 3.1+ serialized cache file
|
|
||||||
.idea/caches/build_file_checksums.ser
|
|
||||||
|
|
||||||
### JetBrains+all Patch ###
|
|
||||||
# Ignores the whole .idea folder and all .iml files
|
|
||||||
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
|
|
||||||
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
|
|
||||||
|
|
||||||
*.iml
|
|
||||||
modules.xml
|
|
||||||
.idea/misc.xml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
# Sonarlint plugin
|
|
||||||
.idea/sonarlint
|
|
||||||
|
|
||||||
### Maven ###
|
|
||||||
target/
|
|
||||||
pom.xml.tag
|
|
||||||
pom.xml.releaseBackup
|
|
||||||
pom.xml.versionsBackup
|
|
||||||
pom.xml.next
|
|
||||||
release.properties
|
|
||||||
dependency-reduced-pom.xml
|
|
||||||
buildNumber.properties
|
|
||||||
.mvn/timing.properties
|
|
||||||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
|
||||||
.mvn/wrapper/maven-wrapper.jar
|
|
||||||
|
|
||||||
### VisualStudioCode ###
|
|
||||||
.vscode/*
|
|
||||||
!.vscode/settings.json
|
|
||||||
!.vscode/tasks.json
|
|
||||||
!.vscode/launch.json
|
|
||||||
!.vscode/extensions.json
|
|
||||||
*.code-workspace
|
|
||||||
|
|
||||||
### VisualStudioCode Patch ###
|
|
||||||
# Ignore all local history of files
|
|
||||||
.history
|
|
||||||
.ionide
|
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,maven,java,jetbrains+all
|
|
||||||
31
Jenkinsfile
vendored
31
Jenkinsfile
vendored
@@ -1,27 +1,32 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
tools {
|
|
||||||
maven "maven_jenkins"
|
|
||||||
}
|
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage ('Compile Stage') {
|
stage ('Compile Stage') {
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
sh 'mvn clean compile'
|
withMaven(maven : 'maven_3_5_0') {
|
||||||
}
|
sh 'mvn clean install'
|
||||||
}
|
}
|
||||||
stage ('Testing Stage') {
|
|
||||||
steps {
|
|
||||||
sh 'mvn test'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage ('Installing Stage') {
|
stage ('Testing Stage') {
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
sh 'mvn install'
|
withMaven(maven : 'maven_3_5_0') {
|
||||||
|
sh 'mvn test'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Generate HTML report') {
|
||||||
|
steps {
|
||||||
|
cucumber buildStatus: "UNSTABLE",
|
||||||
|
fileIncludePattern: '**/cucumber.json',
|
||||||
|
jsonReportDirectory: 'target'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,4 @@
|
|||||||
### Fizz Buzz is a game where
|
### Fizz Buzz is a game where
|
||||||
- if the number is divisible by 3, you say Fizz
|
- if the number is divisible by 3, you say Fizz
|
||||||
- if the number is divisible by 5, you say Buzz
|
- if the number is divisible by 5, you say Buzz
|
||||||
- if neither, you say the number
|
- if neither, you say the number
|
||||||
|
|
||||||
### Contributors
|
|
||||||
This a Jenkinsfile Multibranch pipeline example
|
|
||||||
30
pom.xml
30
pom.xml
@@ -6,14 +6,12 @@
|
|||||||
|
|
||||||
<groupId>com.techprimers.testing</groupId>
|
<groupId>com.techprimers.testing</groupId>
|
||||||
<artifactId>jenkins-example</artifactId>
|
<artifactId>jenkins-example</artifactId>
|
||||||
<version>20201020</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
|
||||||
<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>
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/test/java/com/techprimers/testing/CucumberTest.java
Normal file
14
src/test/java/com/techprimers/testing/CucumberTest.java
Normal 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 {
|
||||||
|
}
|
||||||
26
src/test/java/com/techprimers/testing/FizzBuzzStepdefs.java
Normal file
26
src/test/java/com/techprimers/testing/FizzBuzzStepdefs.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/test/resources/FizzBuzz.feature
Normal file
16
src/test/resources/FizzBuzz.feature
Normal 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"
|
||||||
Reference in New Issue
Block a user