Skip to content

Commit 1316d95

Browse files
committed
#18: Se agregan los tests de aceptación a las tareas de gradle
1 parent 05959b6 commit 1316d95

5 files changed

Lines changed: 34 additions & 2 deletions

File tree

build.gradle

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,23 @@ configurations {
1919
pmdConf
2020
}
2121

22+
sourceSets {
23+
acceptanceTest {
24+
java.srcDir file('src/acceptance-tests/java')
25+
resources.srcDir file('src/acceptance-tests/resources')
26+
}
27+
}
28+
2229
dependencies {
2330
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
24-
testCompile group: 'junit', name: 'junit', version: '4.+'
31+
testCompile 'junit:junit:4.+'
2532
testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.2.1'
2633
pmdConf group: 'pmd', name: 'pmd', version: '4.3'
34+
35+
acceptanceTestCompile sourceSets.main.output
36+
acceptanceTestCompile configurations.testCompile
37+
acceptanceTestCompile sourceSets.test.output
38+
acceptanceTestRuntime configurations.testRuntime
2739
}
2840

2941
buildscript {
@@ -37,6 +49,13 @@ buildscript {
3749

3850
// Tareas
3951

52+
task acceptanceTest(type: Test) {
53+
description = "Corre los tests de aceptación"
54+
testClassesDir = sourceSets.acceptanceTest.output.classesDir
55+
classpath = sourceSets.acceptanceTest.runtimeClasspath
56+
acceptanceTest.reports.html.destination = file("$buildDir/reports/acceptance-tests")
57+
}
58+
4059
task wrapper(type: Wrapper) {
4160
gradleVersion = '1.9'
4261
}
@@ -80,4 +99,4 @@ task pmd (dependsOn: compileJava) << {
8099
}
81100
}
82101
}
83-
}
102+
}

src/acceptance-tests/java/jwarrior/Nivel01AcceptanceTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package jwarrior;
22

3+
import static org.hamcrest.CoreMatchers.is;
4+
import static org.junit.Assert.assertThat;
35
import jwarrior.juego.Juego;
46
import jwarrior.juego.niveles.Nivel01;
57
import jwarrior.jugadores.JugadorNivel01;
@@ -12,5 +14,6 @@ public class Nivel01AcceptanceTest {
1214
public void test() {
1315
Juego coordinador = new Juego(new Nivel01(new JugadorNivel01()));
1416
coordinador.jugar();
17+
assertThat(coordinador.obtenerPuntaje(), is(16));
1518
}
1619
}

src/acceptance-tests/java/jwarrior/Nivel02AcceptanceTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package jwarrior;
22

3+
import static org.hamcrest.CoreMatchers.is;
4+
import static org.junit.Assert.assertThat;
35
import jwarrior.juego.Juego;
46
import jwarrior.juego.niveles.Nivel02;
57
import jwarrior.jugadores.JugadorNivel02;
@@ -12,5 +14,6 @@ public class Nivel02AcceptanceTest {
1214
public void test() {
1315
Juego coordinador = new Juego(new Nivel02(new JugadorNivel02()));
1416
coordinador.jugar();
17+
assertThat(coordinador.obtenerPuntaje(), is(26));
1518
}
1619
}

src/acceptance-tests/java/jwarrior/Nivel03AcceptanceTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import jwarrior.juego.niveles.Nivel03;
55
import jwarrior.jugadores.JugadorNivel03;
66

7+
import static org.hamcrest.CoreMatchers.is;
8+
import static org.junit.Assert.assertThat;
79
import org.junit.Test;
810

911
public class Nivel03AcceptanceTest {
@@ -12,5 +14,6 @@ public class Nivel03AcceptanceTest {
1214
public void test() {
1315
Juego coordinador = new Juego(new Nivel03(new JugadorNivel03()));
1416
coordinador.jugar();
17+
assertThat(coordinador.obtenerPuntaje(), is(26));
1518
}
1619
}

src/main/java/jwarrior/juego/Juego.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public Unidad obtenerGuerrero() {
2626
return this.mapa.obtenerGuerrero();
2727
}
2828

29+
public Integer obtenerPuntaje() {
30+
return this.controlPuntaje.obtenerPuntaje();
31+
}
32+
2933
private void mensaje(final String mensaje) {
3034
InterfazDeUsuario.obtenerInstancia().mensaje(mensaje);
3135
}

0 commit comments

Comments
 (0)