data/profiles/test.profile | 1 +
rails/test/GameTest.java | 23 -----------------------
test/TestGame.java | 17 +++++++++++++++--
test/TestGameBuilder.java | 37 +++++++++++++++++++++++--------------
4 files changed, 39 insertions(+), 39 deletions(-)
New commits:
commit a3aed45bb43b36c663be37682bb9c234a8a16a83
Author: Stefan Frey <ste...@we...>
Date: Fri Aug 5 17:00:08 2011 +0200
TestGame creates a failed report
diff --git a/data/profiles/test.profile b/data/profiles/test.profile
index 10dd67c..06be5fc 100644
--- a/data/profiles/test.profile
+++ b/data/profiles/test.profile
@@ -63,6 +63,7 @@ save.filename.extension=rails
# The date/time pattern must be as defined in the Java SimpleDateFormat class.
#report.filename.date_time_pattern=yyyyMMdd
report.filename.extension=report
+failed.filename.extension=failed
### Windows
## Report window visibility
diff --git a/test/TestGame.java b/test/TestGame.java
index 0769927..3556073 100644
--- a/test/TestGame.java
+++ b/test/TestGame.java
@@ -23,6 +23,8 @@ public class TestGame extends TestCase {
private List<String> testReport = null;
private List<String> expectedReport = null;
+ private boolean passed = false;
+
protected static Logger log =
Logger.getLogger(TestGame.class.getPackage().getName());
@@ -66,6 +68,7 @@ public class TestGame extends TestCase {
expectedReport.get(line), testReport.get(line));
line = line + 1;
}
+ passed = true;
}
protected void setUp() throws Exception {
@@ -105,11 +108,21 @@ public class TestGame extends TestCase {
}
protected void tearDown() throws Exception {
+ // test has failed, so save the test Report
+ String reportFilename = gamePath + File.separator + gameName + "." + Config.get("failed.filename.extension");
+ if (!passed) {
+ TestGameBuilder.saveGameReport(testReport, reportFilename, true);
+ } else { // otherwise check if the test Report exists and delete it
+ File f = new File(reportFilename);
+ if (f.exists()) {
+ if (f.delete()) {
+ System.out.println("Deleted failed report at " + reportFilename);
+ }
+ }
+ }
super.tearDown();
testReport.clear();
expectedReport.clear();
-
-
}
}
diff --git a/test/TestGameBuilder.java b/test/TestGameBuilder.java
index bdbc978..7702ffb 100644
--- a/test/TestGameBuilder.java
+++ b/test/TestGameBuilder.java
@@ -30,6 +30,28 @@ public final class TestGameBuilder extends TestCase {
// true = optimal for ant html reports, false = optimal for test runner
private static boolean extendedTestNames = true;
+ static void saveGameReport(List<String> report, String reportFilename, boolean failed) {
+ PrintWriter reportFile = null;
+ try{
+ reportFile = new PrintWriter(reportFilename);
+ } catch (IOException e)
+ {
+ System.err.print("Error: cannot open file " + reportFilename + " for report writing");
+ }
+ if (reportFile != null) {
+ for (String msg:report){
+ reportFile.println(msg);
+ }
+ reportFile.close();
+ if (failed) {
+ System.out.println("Created failed report at " + reportFilename);
+ } else {
+ System.out.println("Created base line report file at " + reportFilename);
+ }
+ }
+ }
+
+
private static void prepareGameReport(File gameFile, String reportFilename) {
Game game = null;
@@ -39,21 +61,8 @@ public final class TestGameBuilder extends TestCase {
if (game != null) {
List<String> report = ReportBuffer.getAsList();
+ saveGameReport(report, reportFilename, false);
NDC.clear(); // remove reference to GameManager
- PrintWriter reportFile = null;
- try{
- reportFile = new PrintWriter(reportFilename);
- } catch (IOException e)
- {
- System.err.print("Cannot open file " + reportFilename + " to save game report");
- }
- if (reportFile != null) {
- for (String msg:report){
- reportFile.println(msg);
- }
- reportFile.close();
- System.out.println("Created reportfile at " + reportFilename);
- }
}
}
commit 42d85295292965303c14926c41d83cdb375c1c83
Author: Stefan Frey <ste...@we...>
Date: Fri Aug 5 16:19:45 2011 +0200
Removed GameTest
diff --git a/rails/test/GameTest.java b/rails/test/GameTest.java
deleted file mode 100644
index 4bab9a6..0000000
--- a/rails/test/GameTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package rails.test;
-
-import rails.common.parser.Config;
-import rails.ui.swing.GameSetupWindow;
-
-public class GameTest {
-
- public static void main(String[] args) {
-
- // intialize configuration
- Config.setConfigSelection();
-
- int nargs = 0;
- if (args != null && args.length > 0) {
- for (String arg : args) {
- System.out.println ("Arg "+(++nargs)+": "+arg);
- }
- }
-
- /* Start the rails.game selector, which will do all the rest. */
- new GameSetupWindow();
- }
-}
|