1 | /*
|
---|
2 | * Copyright (C) 1997 Pharos IP Pty Ltd
|
---|
3 | * $Id: Test.java 10737 2005-10-19 03:06:40Z kjdon $
|
---|
4 | * $Source$
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | */
|
---|
20 |
|
---|
21 | package au.com.pharos.test;
|
---|
22 |
|
---|
23 | /** Utilities for automated testing. This class contains only static
|
---|
24 | * functions and should not be instantiated.
|
---|
25 | *
|
---|
26 | * @author Martin Pool
|
---|
27 | * @version $Revision: 10737 $ $Date: 2005-10-19 03:06:40 +0000 (Wed, 19 Oct 2005) $
|
---|
28 | **/
|
---|
29 | // TODO: Somehow automatically generate sequence numbers, or perhaps use
|
---|
30 | // strings to report progress
|
---|
31 | public class Test {
|
---|
32 | // Don't instantiate
|
---|
33 | private Test() {}
|
---|
34 |
|
---|
35 | static int nPassed, nFailed;
|
---|
36 |
|
---|
37 | /** Register that a particular test executed successfully, and
|
---|
38 | * output a success or failure message.
|
---|
39 | *
|
---|
40 | * @param number test sequence number
|
---|
41 | **/
|
---|
42 | static public void ok(int no) {
|
---|
43 | ok(no, true);
|
---|
44 | }
|
---|
45 |
|
---|
46 | /** Register the result of a test, and output a success or failure
|
---|
47 | * message.
|
---|
48 | *
|
---|
49 | * @param number test sequence number
|
---|
50 | * @param result whether the test was successful or not
|
---|
51 | */
|
---|
52 | static public void ok(int number, boolean passed) {
|
---|
53 | if (passed) {
|
---|
54 | nPassed++;
|
---|
55 | }
|
---|
56 | else {
|
---|
57 | System.out.print("not ");
|
---|
58 | nFailed++;
|
---|
59 | }
|
---|
60 | System.out.print("ok " + number + "\n");
|
---|
61 | }
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Print a summary of test results.
|
---|
65 | **/
|
---|
66 | static public void summary() {
|
---|
67 | System.out.print("test summary: " + nPassed + " passed, " +
|
---|
68 | nFailed + " failed");
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|