-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setting up project and adding canary test
- Loading branch information
1 parent
6e42460
commit cf65ed1
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ | |
*.jar | ||
*.war | ||
*.ear | ||
|
||
.classpath | ||
.project | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<project name="EightPuzzle" default="spock" basedir="."> | ||
|
||
<path id="srcpath"> | ||
<pathelement location="src" /> | ||
<pathelement location="spock" /> | ||
</path> | ||
|
||
<path id="project.classpath"> | ||
<fileset dir="lib"> | ||
<include name="*.jar" /> | ||
</fileset> | ||
</path> | ||
|
||
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="project.classpath" /> | ||
<target name="spock"> | ||
<property name="tests.build" value="build" /> | ||
<property name="tests.classes" value="${tests.build}/classes" /> | ||
<property name="spock.reports" value="${tests.build}/spock-reports" /> | ||
<delete dir="${tests.build}" /> | ||
<mkdir dir="${tests.classes}" /> | ||
<mkdir dir="${spock.reports}" /> | ||
|
||
<groovyc destdir="${tests.classes}"> | ||
<classpath refid="project.classpath" /> | ||
<src path="src" /> | ||
<src path="spock" /> | ||
<include name="**/*.java" /> | ||
<include name="**/*.groovy" /> | ||
<javac source="1.7" target="1.7" debug="on" /> | ||
</groovyc> | ||
|
||
<groovyc srcdir="spock" destdir="${tests.classes}" classpathref="project.classpath" /> | ||
|
||
<junit failureproperty="test.failure" > | ||
<formatter type="plain" /> | ||
<classpath path="${tests.classes}" /> | ||
<classpath refid="project.classpath" /> | ||
<batchtest fork="yes" todir="${spock.reports}" > | ||
<fileset dir="${tests.classes}"> | ||
<include name="**/*Tests.class" /> | ||
</fileset> | ||
</batchtest> | ||
</junit> | ||
|
||
<fail message="Tests failed" if="test.failure" /> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import spock.lang.* | ||
import com.greenmoonsoftware.eightpuzzle.* | ||
|
||
class SolverTests extends spock.lang.Specification { | ||
def "canary test"() { | ||
when: | ||
def solver = new Solver("1234567890") | ||
def result = solver.solve() | ||
then: | ||
result != null | ||
result.moves == 0 | ||
result.calculations == 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.greenmoonsoftware.eightpuzzle; | ||
|
||
public class Result { | ||
private final int moves; | ||
private final int calculations; | ||
|
||
public Result(int moves, int calculations) { | ||
this.moves = moves; | ||
this.calculations = calculations; | ||
} | ||
|
||
public int getCalculations() { | ||
return calculations; | ||
} | ||
|
||
public int getMoves() { | ||
return moves; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.greenmoonsoftware.eightpuzzle; | ||
|
||
|
||
public class Solver { | ||
private final String puzzleLayout; | ||
|
||
public Solver(String puzzleLayout) { | ||
this.puzzleLayout = puzzleLayout; | ||
} | ||
|
||
public Result solve() { | ||
return new Result(0,1); | ||
} | ||
} |