public static void run(Class test) { String args[]= { test.getName() }; main(args); }
public static void main(String[] args) { new TestRunner().start(args); }
/** * Starts the TestRunner */ public void start(String[] args) { String suiteName= processArguments(args); fFrame= createUI(suiteName); fFrame.setLocation(200, 200); fFrame.setVisible(true); if (suiteName != null) { setSuiteName(suiteName); runSuite(); } } }
protected Frame createUI(String suiteName) { Frame frame= new Frame("JUnit"); Image icon= loadFrameIcon(); if (icon != null) frame.setIconImage(icon); createMenus(mb); frame.setMenuBar(mb); boolean useLoader= useReloadingTestSuiteLoader(); fUseLoadingRunner= new Checkbox("Reload classes every run", useLoader); if (inVAJava()) fUseLoadingRunner.setVisible(false); Panel numbersPanel= createCounterPanel(); addGrid(panel, suiteLabel, 0, 0, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST); addGrid(panel, fSuiteField, 0, 1, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST); addGrid(panel, fRun, 2, 1, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.CENTER); addGrid(panel, fUseLoadingRunner, 0, 2, 2, GridBagConstraints.NONE, 1.0, GridBagConstraints.WEST); addGrid(panel, fProgressIndicator, 0, 3, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST); addGrid(panel, fLogo, 2, 3, 1, GridBagConstraints.NONE, 0.0, GridBagConstraints.NORTH); addGrid(panel, numbersPanel, 0, 4, 2, GridBagConstraints.NONE, 0.0, GridBagConstraints.WEST); addGrid(panel, failureLabel, 0, 5, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST); addGrid(panel, fFailureList, 0, 6, 2, GridBagConstraints.BOTH, 1.0, GridBagConstraints.WEST); addGrid(panel, failedPanel, 2, 6, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.CENTER); addGrid(panel, fTraceArea, 0, 7, 2, GridBagConstraints.BOTH, 1.0, GridBagConstraints.WEST);
public void run() { fTestResult= createTestResult(); fTestResult.addListener(TestRunner.this); fProgressIndicator.start(testSuite.countTestCases()); showInfo("Running..."); long startTime= System.currentTimeMillis(); testSuite.run(fTestResult); if (fTestResult.shouldStop()) { showStatus("Stopped"); } else { long endTime= System.currentTimeMillis(); long runTime= endTime-startTime; showInfo("Finished: " + elapsedTimeAsString(runTime) + " seconds"); } fTestResult= null; fRun.setLabel("Run"); fRunner= null; System.gc(); } };
protected void createMenus(MenuBar mb) { mb.add(createJUnitMenu()); } protected TestResult createTestResult() {
public void testFailed(int status, Test test, Throwable t) { switch (status) { case TestRunListener.STATUS_ERROR: fNumberOfErrors.setText(Integer.toString(fTestResult.errorCount())); appendFailure("Error", test, t); break; case TestRunListener.STATUS_FAILURE: fNumberOfFailures.setText(Integer.toString(fTestResult.failureCount())); appendFailure("Failure", test, t); break; } }
protected Panel createCounterPanel() { Panel numbersPanel= new Panel(new GridBagLayout()); addToCounterPanel( numbersPanel, new Label("Runs:"), new Insets(0, 0, 0, 0) ); addToCounterPanel( numbersPanel, fNumberOfRuns, new Insets(0, 8, 0, 40) ); addToCounterPanel( numbersPanel, new Label("Errors:"), new Insets(0, 8, 0, 0) ); addToCounterPanel( numbersPanel, fNumberOfErrors, new Insets(0, 8, 0, 40) ); addToCounterPanel( numbersPanel, new Label("Failures:"),
public static void main(String[] args) { junit.awtui.TestRunner.main(new String[] { TestMockBase.class.getName() }); }