Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
XU CHENGLIN
tp-gl-demo
Commits
c70b17d5
Commit
c70b17d5
authored
Nov 05, 2020
by
Léa Рая DÉCORNOD
Browse files
Merge branch 'feature/4-bdd' into 'develop'
[#4] use cucumber & sceanrio See merge request
decornod/tp-gl-demo!4
parents
27d5ff3e
8b08422f
Changes
4
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
c70b17d5
...
...
@@ -6,8 +6,11 @@ plugins {
sourceCompatibility
=
1.11
dependencies
{
testImplementation
'org.junit.jupiter:junit-jupiter-api:5.6.0'
testRuntimeOnly
'org.junit.jupiter:junit-jupiter-engine:5.6.0'
testImplementation
'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly
'org.junit.jupiter:junit-jupiter-engine:5.7.0'
testImplementation
'io.cucumber:cucumber-java:6.8.2'
testImplementation
'io.cucumber:cucumber-junit-platform-engine:6.8.2'
}
test
{
...
...
src/test/java/fr/unistra/mathinfo/gl/tp/demo/CucumberSupport.java
0 → 100644
View file @
c70b17d5
package
fr.unistra.mathinfo.gl.tp.demo
;
import
io.cucumber.junit.platform.engine.Cucumber
;
@Cucumber
public
class
CucumberSupport
{
}
src/test/java/fr/unistra/mathinfo/gl/tp/demo/steps/BDDSteps.java
0 → 100644
View file @
c70b17d5
package
fr.unistra.mathinfo.gl.tp.demo.steps
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
fail
;
import
fr.unistra.mathinfo.gl.tp.demo.FizzBuzz
;
import
fr.unistra.mathinfo.gl.tp.demo.FizzBuzzImpl
;
import
io.cucumber.java.en.Given
;
import
io.cucumber.java.en.Then
;
import
io.cucumber.java.en.When
;
public
class
BDDSteps
{
private
static
class
State
{
private
FizzBuzz
fizzBuzz
;
private
int
nombre
;
private
String
resultat
;
public
Exception
erreur
;
}
private
State
state
;
@Given
(
"En tant que joueur en position {int}"
)
public
void
en_tant_que_joueur_en_position
(
int
nombre
)
{
state
=
new
State
();
state
.
nombre
=
nombre
;
state
.
fizzBuzz
=
new
FizzBuzzImpl
();
}
@When
(
"Je joue"
)
public
void
je_joue
()
{
try
{
state
.
resultat
=
state
.
fizzBuzz
.
convert
(
state
.
nombre
);
}
catch
(
Exception
e
)
{
state
.
erreur
=
e
;
}
}
@Then
(
"J'ai dit {word}"
)
public
void
j_ai_dit
(
String
attendu
)
{
if
(
state
.
erreur
!=
null
)
fail
(
state
.
erreur
);
assertEquals
(
attendu
,
state
.
resultat
);
}
@Then
(
"Une erreur {word} s'est produite"
)
public
void
erreur
(
String
erreur
)
{
if
(
state
.
erreur
==
null
||
!
erreur
.
equals
(
state
.
erreur
.
getClass
().
getSimpleName
()))
fail
(
"Aucune erreur "
+
erreur
+
" ne s'est produite"
);
}
}
src/test/resources/fr/unistra/mathinfo/gl/tp/demo/FizzBuzz.feature
0 → 100644
View file @
c70b17d5
Feature
:
FizzBuzz
FizzBuzz pour division par 3 ou 5
Scenario Outline
:
Situations FizzBuzz
Given
En tant que joueur en position
<nombre>
When
Je joue
Then
J'ai dit
<attendu>
Examples
:
|
nombre
|
attendu
|
|
13
|
13
|
|
9
|
Fizz
|
|
20
|
Buzz
|
|
15
|
FizzBuzz
|
Scenario Outline
:
Situations inattendues FizzBuzz
Given
En tant que joueur en position
<nombre>
When
Je joue
Then
Une erreur
<erreur>
s'est produite
Examples
:
|
nombre
|
erreur
|
|
-5
|
IllegalArgumentException
|
|
0
|
IllegalArgumentException
|
|
101
|
IllegalArgumentException
|
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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