jmathlib.tools.junit.swingui
Class TestRunner

java.lang.Object
  extended by jmathlib.tools.junit.runner.BaseTestRunner
      extended by jmathlib.tools.junit.swingui.TestRunner
All Implemented Interfaces:
TestListener, TestRunContext

public class TestRunner
extends BaseTestRunner
implements TestRunContext

A Swing based user interface to run tests. Enter the name of a class which either provides a static suite method or is a subclass of TestCase.

 Synopsis: java junit.swingui.TestRunner [-noloading] [TestCase]
 
TestRunner takes as an optional argument the name of the testcase class to be run.


Field Summary
private static java.awt.Font BOLD_FONT
           
private static java.lang.String FAILUREDETAILVIEW_KEY
           
private  CounterPanel fCounterPanel
           
private  javax.swing.DefaultListModel fFailures
           
private  FailureDetailView fFailureView
           
protected  javax.swing.JFrame fFrame
           
private  javax.swing.JLabel fLogo
           
private  ProgressBar fProgressIndicator
           
private  javax.swing.JButton fQuitButton
           
private  javax.swing.JButton fRerunButton
           
private  javax.swing.JButton fRun
           
private  java.lang.Thread fRunner
           
private  StatusLine fStatusLine
           
private  javax.swing.JComboBox fSuiteCombo
           
private  TestResult fTestResult
           
private  java.util.Vector fTestRunViews
           
private  javax.swing.JTabbedPane fTestViewTab
           
private  javax.swing.JCheckBox fUseLoadingRunner
           
private static int GAP
           
private static int HISTORY_LENGTH
           
private static java.awt.Font PLAIN_FONT
           
private static java.lang.String TESTCOLLECTOR_KEY
           
 
Fields inherited from class jmathlib.tools.junit.runner.BaseTestRunner
SUITE_METHODNAME
 
Constructor Summary
TestRunner()
           
 
Method Summary
private  void about()
           
protected  void aboutToStart(Test testSuite)
           
 void addError(Test test, java.lang.Throwable t)
          An error occurred.
 void addFailure(Test test, AssertionFailedError t)
          A failure occurred.
private  void addGrid(javax.swing.JPanel p, java.awt.Component co, int x, int y, int w, int fill, double wx, int anchor)
           
private  void addToHistory(java.lang.String suite)
           
private  void appendFailure(java.lang.String kind, Test test, java.lang.Throwable t)
           
 void browseTestClasses()
           
protected  void clearStatus()
          Clears the status message.
protected  java.awt.Component createBrowseButton()
           
protected  CounterPanel createCounterPanel()
           
protected  javax.swing.JPanel createFailedPanel()
           
protected  FailureDetailView createFailureDetailView()
           
protected  javax.swing.JFrame createFrame(java.lang.String title)
           
protected  javax.swing.JMenu createJUnitMenu()
          Creates the JUnit menu.
protected  javax.swing.JLabel createLogo()
           
protected  void createMenus(javax.swing.JMenuBar mb)
           
protected  javax.swing.JButton createQuitButton()
           
protected  javax.swing.JButton createRunButton()
           
protected  StatusLine createStatusLine()
           
protected  javax.swing.JComboBox createSuiteCombo()
           
(package private)  TestCollector createTestCollector()
           
protected  TestResult createTestResult()
           
protected  javax.swing.JTabbedPane createTestRunViews()
           
protected  javax.swing.JFrame createUI(java.lang.String suiteName)
           
protected  javax.swing.JCheckBox createUseLoaderCheckBox()
           
private  void doRunTest(Test testSuite)
           
 void endTest(Test test)
          A test ended.
 javax.swing.ListModel getFailures()
          Returns the failure model
static javax.swing.Icon getIconResource(java.lang.Class clazz, java.lang.String name)
           
private  java.io.File getSettingsFile()
           
protected  java.lang.String getSuiteText()
           
 void handleTestSelected(Test test)
          Handles the selection of a Test.
 void insertUpdate(javax.swing.event.DocumentEvent event)
           
private  java.awt.Image loadFrameIcon()
           
private  void loadHistory(javax.swing.JComboBox combo)
           
static void main(java.lang.String[] args)
           
private  void postEndTest(Test test)
           
private  void postInfo(java.lang.String message)
           
private  void postStatus(java.lang.String status)
           
private  void pruneHistory()
           
 void removeUpdate(javax.swing.event.DocumentEvent event)
           
private  void rerun()
           
private  void rerunTest(Test test)
           
protected  void reset()
           
private  void revealFailure(Test test)
           
 void run()
          Deprecated. use runSuite() instead
static void run(java.lang.Class test)
           
protected  void runFailed(java.lang.String message)
          Override to define how to handle a failed loading of a test suite.
protected  void runFinished(Test testSuite)
           
 void runSuite()
           
protected  void runTest(Test testSuite)
           
private  void saveHistory()
           
private  void setButtonLabel(javax.swing.JButton button, java.lang.String label)
           
private  void setLabelValue(javax.swing.JTextField label, int value)
           
 void setSuite(java.lang.String suiteName)
           
private  boolean shouldReload()
           
private  void showFailureDetail(Test test)
           
private  void showInfo(java.lang.String message)
           
private  void showStatus(java.lang.String status)
           
 void start(java.lang.String[] args)
          Starts the TestRunner
private  void start(Test test)
           
 void startTest(Test test)
          A test started.
private  void synchUI()
          Wait until all the events are processed in the event thread
 void terminate()
          Terminates the TestRunner
 void testViewChanged()
           
 void textChanged()
           
 
Methods inherited from class jmathlib.tools.junit.runner.BaseTestRunner
elapsedTimeAsString, extractClassName, filterStack, getFilteredTrace, getLoader, getPreference, getPreference, getTest, inVAJava, loadSuiteClass, processArguments, setLoading, truncate, useReloadingTestSuiteLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fFrame

protected javax.swing.JFrame fFrame

fRunner

private java.lang.Thread fRunner

fTestResult

private TestResult fTestResult

fSuiteCombo

private javax.swing.JComboBox fSuiteCombo

fProgressIndicator

private ProgressBar fProgressIndicator

fFailures

private javax.swing.DefaultListModel fFailures

fLogo

private javax.swing.JLabel fLogo

fCounterPanel

private CounterPanel fCounterPanel

fRun

private javax.swing.JButton fRun

fQuitButton

private javax.swing.JButton fQuitButton

fRerunButton

private javax.swing.JButton fRerunButton

fStatusLine

private StatusLine fStatusLine

fFailureView

private FailureDetailView fFailureView

fTestViewTab

private javax.swing.JTabbedPane fTestViewTab

fUseLoadingRunner

private javax.swing.JCheckBox fUseLoadingRunner

fTestRunViews

private java.util.Vector fTestRunViews

PLAIN_FONT

private static java.awt.Font PLAIN_FONT

BOLD_FONT

private static java.awt.Font BOLD_FONT

GAP

private static final int GAP
See Also:
Constant Field Values

HISTORY_LENGTH

private static final int HISTORY_LENGTH
See Also:
Constant Field Values

TESTCOLLECTOR_KEY

private static final java.lang.String TESTCOLLECTOR_KEY
See Also:
Constant Field Values

FAILUREDETAILVIEW_KEY

private static final java.lang.String FAILUREDETAILVIEW_KEY
See Also:
Constant Field Values
Constructor Detail

TestRunner

public TestRunner()
Method Detail

main

public static void main(java.lang.String[] args)

run

public static void run(java.lang.Class test)

addError

public void addError(Test test,
                     java.lang.Throwable t)
Description copied from interface: TestListener
An error occurred.

Specified by:
addError in interface TestListener

addFailure

public void addFailure(Test test,
                       AssertionFailedError t)
Description copied from interface: TestListener
A failure occurred.

Specified by:
addFailure in interface TestListener

startTest

public void startTest(Test test)
Description copied from interface: TestListener
A test started.

Specified by:
startTest in interface TestListener

endTest

public void endTest(Test test)
Description copied from interface: TestListener
A test ended.

Specified by:
endTest in interface TestListener

postEndTest

private void postEndTest(Test test)

setSuite

public void setSuite(java.lang.String suiteName)

addToHistory

private void addToHistory(java.lang.String suite)

pruneHistory

private void pruneHistory()

appendFailure

private void appendFailure(java.lang.String kind,
                           Test test,
                           java.lang.Throwable t)

revealFailure

private void revealFailure(Test test)

aboutToStart

protected void aboutToStart(Test testSuite)

runFinished

protected void runFinished(Test testSuite)

createCounterPanel

protected CounterPanel createCounterPanel()

createFailedPanel

protected javax.swing.JPanel createFailedPanel()

createFailureDetailView

protected FailureDetailView createFailureDetailView()

createJUnitMenu

protected javax.swing.JMenu createJUnitMenu()
Creates the JUnit menu. Clients override this method to add additional menu items.


createFrame

protected javax.swing.JFrame createFrame(java.lang.String title)

createLogo

protected javax.swing.JLabel createLogo()

createMenus

protected void createMenus(javax.swing.JMenuBar mb)

createUseLoaderCheckBox

protected javax.swing.JCheckBox createUseLoaderCheckBox()

createQuitButton

protected javax.swing.JButton createQuitButton()

createRunButton

protected javax.swing.JButton createRunButton()

createBrowseButton

protected java.awt.Component createBrowseButton()

createStatusLine

protected StatusLine createStatusLine()

createSuiteCombo

protected javax.swing.JComboBox createSuiteCombo()

createTestRunViews

protected javax.swing.JTabbedPane createTestRunViews()

testViewChanged

public void testViewChanged()

createTestResult

protected TestResult createTestResult()

createUI

protected javax.swing.JFrame createUI(java.lang.String suiteName)

addGrid

private void addGrid(javax.swing.JPanel p,
                     java.awt.Component co,
                     int x,
                     int y,
                     int w,
                     int fill,
                     double wx,
                     int anchor)

getSuiteText

protected java.lang.String getSuiteText()

getFailures

public javax.swing.ListModel getFailures()
Description copied from interface: TestRunContext
Returns the failure model

Specified by:
getFailures in interface TestRunContext

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent event)

browseTestClasses

public void browseTestClasses()

createTestCollector

TestCollector createTestCollector()

loadFrameIcon

private java.awt.Image loadFrameIcon()

loadHistory

private void loadHistory(javax.swing.JComboBox combo)
                  throws java.io.IOException
Throws:
java.io.IOException

getSettingsFile

private java.io.File getSettingsFile()

postInfo

private void postInfo(java.lang.String message)

postStatus

private void postStatus(java.lang.String status)

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent event)

rerun

private void rerun()

rerunTest

private void rerunTest(Test test)

reset

protected void reset()

run

public void run()
Deprecated. use runSuite() instead

runs a suite.


runFailed

protected void runFailed(java.lang.String message)
Description copied from class: BaseTestRunner
Override to define how to handle a failed loading of a test suite.

Specified by:
runFailed in class BaseTestRunner

runSuite

public void runSuite()

shouldReload

private boolean shouldReload()

runTest

protected void runTest(Test testSuite)

doRunTest

private void doRunTest(Test testSuite)

saveHistory

private void saveHistory()
                  throws java.io.IOException
Throws:
java.io.IOException

setButtonLabel

private void setButtonLabel(javax.swing.JButton button,
                            java.lang.String label)

setLabelValue

private void setLabelValue(javax.swing.JTextField label,
                           int value)

handleTestSelected

public void handleTestSelected(Test test)
Description copied from interface: TestRunContext
Handles the selection of a Test.

Specified by:
handleTestSelected in interface TestRunContext

showFailureDetail

private void showFailureDetail(Test test)

showInfo

private void showInfo(java.lang.String message)

showStatus

private void showStatus(java.lang.String status)

start

public void start(java.lang.String[] args)
Starts the TestRunner


start

private void start(Test test)

synchUI

private void synchUI()
Wait until all the events are processed in the event thread


terminate

public void terminate()
Terminates the TestRunner


textChanged

public void textChanged()

clearStatus

protected void clearStatus()
Description copied from class: BaseTestRunner
Clears the status message.

Overrides:
clearStatus in class BaseTestRunner

getIconResource

public static javax.swing.Icon getIconResource(java.lang.Class clazz,
                                               java.lang.String name)

about

private void about()

FOOTER

BOTTOM