Skip to content

Commit

Permalink
first test
Browse files Browse the repository at this point in the history
rock beats scissors
  • Loading branch information
youngnh committed Dec 11, 2009
1 parent 7b78e5e commit 4b28c63
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
build/*
61 changes: 61 additions & 0 deletions build.xml
@@ -0,0 +1,61 @@
<project name="RockPaperScissors" default="dist" basedir=".">
<property name="src" location="src" />
<property name="test" location="test" />
<property name="lib" location="lib" />
<property name="build" location="build" />
<property name="dist" location="dist" />
<property name="classes" location="${build}/classes" />
<property name="test.classes" location="${build}/test-classes" />
<property name="test.report" location="${build}/reports" />

<target name="init">
<tstamp />
<mkdir dir="${classes}" />
<mkdir dir="${test.classes}" />
<mkdir dir="${test.report}" />
<mkdir dir="${dist}" />
</target>

<path id="class.path">
<pathelement location="${classes}" />
<pathelement location="${test.classes}" />
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
</path>

<target name="compile" depends="init">
<javac destdir="${classes}" debug="on">
<src>
<pathelement location="${src}" />
</src>
<classpath refid="class.path" />
</javac>
<javac destdir="${test.classes}" debug="on">
<src>
<pathelement location="${test}" />
</src>
<classpath refid="class.path" />
</javac>
</target>

<target name="test" depends="compile">
<junit printsummary="on" haltonerror="true" haltonfailure="true">
<classpath refid="class.path" />
<batchtest todir="${test.report}">
<formatter type="plain" />
<fileset dir="${test}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>

<target name="dist" depends="test">
<jar destfile="${dist}/${ant.project.name}-${DSTAMP}.jar" basedir="${classes}"/>
</target>

<target name="clean">
<delete dir="${build}" />
</target>
</project>
Binary file added lib/junit.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions src/com/twoguys/rps/Rock.java
@@ -0,0 +1,5 @@
package com.twoguys.rps;

public class Rock extends Throw {

}
5 changes: 5 additions & 0 deletions src/com/twoguys/rps/Scissors.java
@@ -0,0 +1,5 @@
package com.twoguys.rps;

public class Scissors extends Throw {

}
9 changes: 9 additions & 0 deletions src/com/twoguys/rps/Throw.java
@@ -0,0 +1,9 @@
package com.twoguys.rps;

public abstract class Throw {

public boolean beats(Throw other) {
return true;
}

}
16 changes: 16 additions & 0 deletions test/com/twoguys/rps/ThrowTest.java
@@ -0,0 +1,16 @@
package com.twoguys.rps;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class ThrowTest {

@Test
public void testRockBeatsScissors() {
Throw rock = new Rock();
Throw scissors = new Scissors();
boolean result = rock.beats(scissors);
assertTrue(result);
}
}

0 comments on commit 4b28c63

Please sign in to comment.