Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cucumber-tutorial
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kyle Muldoon
cucumber-tutorial
Commits
8118d3ec
Commit
8118d3ec
authored
Apr 06, 2021
by
Kyle Muldoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tests + results for a basic calculator
parent
fddd302e
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
943 additions
and
9 deletions
+943
-9
Calculator.java
src/test/java/hellocucumber/Calculator.java
+12
-0
CalculatorSteps.java
src/test/java/hellocucumber/CalculatorSteps.java
+32
-0
RunCucumberTest.java
src/test/java/hellocucumber/RunCucumberTest.java
+11
-4
calculatorTests.feature
src/test/resources/hellocucumber/calculatorTests.feature
+14
-0
inputFiles.lst
...ler-plugin/testCompile/default-testCompile/inputFiles.lst
+2
-0
TEST-hellocucumber.RunCucumberTest.xml
...t/surefire-reports/TEST-hellocucumber.RunCucumberTest.xml
+8
-4
hellocucumber.RunCucumberTest.txt
target/surefire-reports/hellocucumber.RunCucumberTest.txt
+1
-1
report.json
target/surefire-reports/json/report.json
+382
-0
report.xml
target/surefire-reports/junit/report.xml
+39
-0
report.html
target/surefire-reports/report.html
+428
-0
.gitkeep
target/test-classes/hellocucumber/.gitkeep
+0
-0
Calculator.class
target/test-classes/hellocucumber/Calculator.class
+0
-0
CalculatorSteps.class
target/test-classes/hellocucumber/CalculatorSteps.class
+0
-0
RunCucumberTest.class
target/test-classes/hellocucumber/RunCucumberTest.class
+0
-0
calculatorTests.feature
target/test-classes/hellocucumber/calculatorTests.feature
+14
-0
No files found.
src/test/java/hellocucumber/Calculator.java
0 → 100644
View file @
8118d3ec
package
hellocucumber
;
public
class
Calculator
{
public
Integer
add
(
Integer
l
,
Integer
r
)
{
int
x
=
l
+
r
;
return
x
;
}
// public Long subtract(Long l, Long r) { return l - r; }
// public Long multiply(Long l, Long r) { return l * r; }
// public Long divide(Long l, Long r) { return l / r; }
}
src/test/java/hellocucumber/CalculatorSteps.java
0 → 100644
View file @
8118d3ec
package
hellocucumber
;
import
io.cucumber.java.en.Given
;
import
io.cucumber.java.en.When
;
import
io.cucumber.java.en.Then
;
import
static
org
.
junit
.
Assert
.*;
public
class
CalculatorSteps
{
Calculator
calculator
;
Integer
result
;
@Given
(
"^I have a calculator$"
)
public
void
generateCalculator
()
{
this
.
calculator
=
new
Calculator
();
}
@When
(
"I add {int} and {int}"
)
public
void
addUsingCalculator
(
Integer
l
,
Integer
r
)
{
this
.
result
=
this
.
calculator
.
add
(
l
,
r
);
}
@Then
(
"the result should be {int}"
)
public
void
checkResult
(
Integer
res
)
{
assertEquals
(
this
.
result
,
res
);
}
}
src/test/java/hellocucumber/RunCucumberTest.java
View file @
8118d3ec
...
...
@@ -5,7 +5,14 @@ import io.cucumber.junit.CucumberOptions;
import
org.junit.runner.RunWith
;
@RunWith
(
Cucumber
.
class
)
@CucumberOptions
(
plugin
=
{
"pretty"
})
public
class
RunCucumberTest
{
}
@CucumberOptions
(
plugin
=
{
"pretty"
,
"html:target/surefire-reports/report.html"
,
"json:target/surefire-reports/json/report.json"
,
"junit:target/surefire-reports/junit/report.xml"
}
//,
//tags = "@wip" // only runs things with the @wip tag. Can also do "not @wip" for opposite effect
// monochrome = true // console output will keep the same lightened color (including comments)
)
public
class
RunCucumberTest
{
}
src/test/resources/hellocucumber/calculatorTests.feature
0 → 100644
View file @
8118d3ec
Feature
:
Does my simple calculator work properly?
Everybody wants a functioning calculator
Scenario Outline
:
Add two numbers <num1> & <num2>
Given
I have a calculator
When
I add
<num1>
and
<num2>
Then
the result should be
<total>
Examples
:
|
num1
|
num2
|
total
|
|
-2
|
3
|
1
|
|
10
|
15
|
25
|
|
99
|
-99
|
0
|
|
-1
|
-10
|
-11
|
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
View file @
8118d3ec
/Users/kmuldoon/Dev/practice/testing/cucumber/hellocucumber/src/test/java/hellocucumber/RunCucumberTest.java
/Users/kmuldoon/Dev/practice/testing/cucumber/hellocucumber/src/test/java/hellocucumber/Calculator.java
/Users/kmuldoon/Dev/practice/testing/cucumber/hellocucumber/src/test/java/hellocucumber/StepDefinitions.java
/Users/kmuldoon/Dev/practice/testing/cucumber/hellocucumber/src/test/java/hellocucumber/CalculatorSteps.java
target/surefire-reports/TEST-hellocucumber.RunCucumberTest.xml
View file @
8118d3ec
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite
tests=
"
2"
failures=
"0"
name=
"hellocucumber.RunCucumberTest"
time=
"0.163
"
errors=
"0"
skipped=
"0"
>
<testsuite
tests=
"
6"
failures=
"0"
name=
"hellocucumber.RunCucumberTest"
time=
"0.228
"
errors=
"0"
skipped=
"0"
>
<properties>
<property
name=
"java.runtime.name"
value=
"OpenJDK Runtime Environment"
/>
<property
name=
"java.vm.version"
value=
"15.0.2+7"
/>
...
...
@@ -34,7 +34,7 @@
<property
name=
"library.jansi.path"
value=
"/usr/local/Cellar/maven/3.6.3_1/libexec/lib/jansi-native"
/>
<property
name=
"http.nonProxyHosts"
value=
"local|*.local|169.254/16|*.169.254/16"
/>
<property
name=
"user.home"
value=
"/Users/kmuldoon"
/>
<property
name=
"user.timezone"
value=
"America/
Chicago
"
/>
<property
name=
"user.timezone"
value=
"America/
Los_Angeles
"
/>
<property
name=
"file.encoding"
value=
"UTF-8"
/>
<property
name=
"java.specification.version"
value=
"15"
/>
<property
name=
"user.name"
value=
"kmuldoon"
/>
...
...
@@ -57,6 +57,10 @@
<property
name=
"socksNonProxyHosts"
value=
"local|*.local|169.254/16|*.169.254/16"
/>
<property
name=
"ftp.nonProxyHosts"
value=
"local|*.local|169.254/16|*.169.254/16"
/>
</properties>
<testcase
classname=
"Is it Friday yet?"
name=
"Sunday isn't Friday"
time=
"0.16"
/>
<testcase
classname=
"Is it Friday yet?"
name=
"Friday is Friday"
time=
"0.003"
/>
<testcase
classname=
"Does my simple calculator work properly?"
name=
"Add two numbers -2 & 3"
time=
"0.17"
/>
<testcase
classname=
"Does my simple calculator work properly?"
name=
"Add two numbers 10 & 15"
time=
"0.013"
/>
<testcase
classname=
"Does my simple calculator work properly?"
name=
"Add two numbers 99 & -99"
time=
"0.014"
/>
<testcase
classname=
"Does my simple calculator work properly?"
name=
"Add two numbers -1 & -10"
time=
"0.009"
/>
<testcase
classname=
"Is it Friday yet?"
name=
"Sunday isn't Friday"
time=
"0.009"
/>
<testcase
classname=
"Is it Friday yet?"
name=
"Friday is Friday"
time=
"0.013"
/>
</testsuite>
\ No newline at end of file
target/surefire-reports/hellocucumber.RunCucumberTest.txt
View file @
8118d3ec
-------------------------------------------------------------------------------
Test set: hellocucumber.RunCucumberTest
-------------------------------------------------------------------------------
Tests run:
2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.463
sec
Tests run:
6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.011
sec
target/surefire-reports/json/report.json
0 → 100644
View file @
8118d3ec
This diff is collapsed.
Click to expand it.
target/surefire-reports/junit/report.xml
0 → 100644
View file @
8118d3ec
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<testsuite
errors=
"0"
failures=
"0"
name=
"io.cucumber.core.plugin.JUnitFormatter"
skipped=
"0"
tests=
"6"
time=
"0.255"
>
<testcase
classname=
"Does my simple calculator work properly?"
name=
"Add two numbers -2 & 3"
time=
"0.052"
>
<system-out>
<![CDATA[Given I have a calculator...................................................passed
When I add -2 and 3.........................................................passed
Then the result should be 1.................................................passed
]]>
</system-out>
</testcase>
<testcase
classname=
"Does my simple calculator work properly?"
name=
"Add two numbers 10 & 15"
time=
"0.002"
>
<system-out>
<![CDATA[Given I have a calculator...................................................passed
When I add 10 and 15........................................................passed
Then the result should be 25................................................passed
]]>
</system-out>
</testcase>
<testcase
classname=
"Does my simple calculator work properly?"
name=
"Add two numbers 99 & -99"
time=
"0.005"
>
<system-out>
<![CDATA[Given I have a calculator...................................................passed
When I add 99 and -99.......................................................passed
Then the result should be 0.................................................passed
]]>
</system-out>
</testcase>
<testcase
classname=
"Does my simple calculator work properly?"
name=
"Add two numbers -1 & -10"
time=
"0.002"
>
<system-out>
<![CDATA[Given I have a calculator...................................................passed
When I add -1 and -10.......................................................passed
Then the result should be -11...............................................passed
]]>
</system-out>
</testcase>
<testcase
classname=
"Is it Friday yet?"
name=
"Sunday isn't Friday"
time=
"0.003"
>
<system-out>
<![CDATA[Given today is Sunday.......................................................passed
When I ask whether it's Friday yet..........................................passed
Then I should be told "Nope"................................................passed
]]>
</system-out>
</testcase>
<testcase
classname=
"Is it Friday yet?"
name=
"Friday is Friday"
time=
"0.005"
>
<system-out>
<![CDATA[Given today is Friday.......................................................passed
When I ask whether it's Friday yet..........................................passed
Then I should be told "TGIF"................................................passed
]]>
</system-out>
</testcase>
</testsuite>
target/surefire-reports/report.html
0 → 100644
View file @
8118d3ec
This diff is collapsed.
Click to expand it.
target/test-classes/hellocucumber/.gitkeep
deleted
100644 → 0
View file @
fddd302e
target/test-classes/hellocucumber/Calculator.class
0 → 100644
View file @
8118d3ec
File added
target/test-classes/hellocucumber/CalculatorSteps.class
0 → 100644
View file @
8118d3ec
File added
target/test-classes/hellocucumber/RunCucumberTest.class
View file @
8118d3ec
No preview for this file type
target/test-classes/hellocucumber/calculatorTests.feature
0 → 100644
View file @
8118d3ec
Feature
:
Does my simple calculator work properly?
Everybody wants a functioning calculator
Scenario Outline
:
Add two numbers <num1> & <num2>
Given
I have a calculator
When
I add
<num1>
and
<num2>
Then
the result should be
<total>
Examples
:
|
num1
|
num2
|
total
|
|
-2
|
3
|
1
|
|
10
|
15
|
25
|
|
99
|
-99
|
0
|
|
-1
|
-10
|
-11
|
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment