Skip to content

Commit

Permalink
Setting up project and adding canary test
Browse files Browse the repository at this point in the history
  • Loading branch information
greathouse committed May 22, 2012
1 parent 6e42460 commit cf65ed1
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
*.jar
*.war
*.ear

.classpath
.project
build/
47 changes: 47 additions & 0 deletions build.xml
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>
14 changes: 14 additions & 0 deletions spock/SolverTests.groovy
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
}
}
19 changes: 19 additions & 0 deletions src/com/greenmoonsoftware/eightpuzzle/Result.java
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;
}
}
14 changes: 14 additions & 0 deletions src/com/greenmoonsoftware/eightpuzzle/Solver.java
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);
}
}

0 comments on commit cf65ed1

Please sign in to comment.