01: /******************************************************************************
02: * Copyright (C) Lars Ivar Almli. All rights reserved. *
03: * ---------------------------------------------------------------------------*
04: * This file is part of MActor. *
05: * *
06: * MActor is free software; you can redistribute it and/or modify *
07: * it under the terms of the GNU General Public License as published by *
08: * the Free Software Foundation; either version 2 of the License, or *
09: * (at your option) any later version. *
10: * *
11: * MActor 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 MActor; if not, write to the Free Software *
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19: ******************************************************************************/package org.mactor.ui;
20:
21: import java.io.File;
22: import org.mactor.framework.TestContext;
23: import org.mactor.framework.TestEvent;
24: import org.mactor.framework.TestFeedbackListener;
25: import org.mactor.framework.TestSuiteRunner;
26: import org.mactor.framework.spec.TestSpec;
27:
28: /**
29: * Runs a test without input data (typically when running as a mock)
30: *
31: * @author Lars Ivar Almli
32: */
33: public class MockRunnerCmd {
34: public static void main(String[] args) {
35: if (args.length != 1) {
36: System.out
37: .println("Usage: MockRunnerCmd <test spec input file>");
38: System.exit(1);
39: }
40: try {
41: new TestSuiteRunner(TestSpec
42: .loadFromFile(new File(args[0])))
43: .runAsMock(new SilentTestFeedbackListener());
44: System.exit(0);
45: } catch (Exception e) {
46: System.err.println("Failed to run mock. Error:"
47: + e.getMessage());
48: System.exit(1);
49: }
50: }
51:
52: private static class SilentTestFeedbackListener implements
53: TestFeedbackListener {
54: public void onEvent(TestEvent event, TestContext context) {
55: if (!event.isSuccessful())
56: System.err.println(event.getNode().getName());
57: }
58: }
59: }
|