Class Test
java.lang.Object
java.lang.Thread
org.netbeans.jemmy.ActionProducer
org.netbeans.jemmy.Test
- All Implemented Interfaces:
Runnable, Action, Outputable, Scenario, Timeoutable, Waitable
Jemmy itself provides a way to create tests.
Test should implement org.netbeans.jemmy.Scenario interface.
Test can be executed from command line:
Test elso can be executed by one of the run(...) methods or by
Timeouts used:
Test.WholeTestTimeout - time for the whole test
java [application options] [jemmy options] org.netbeans.jemmy.Test [full name of test class] [test args]Test elso can be executed by one of the run(...) methods or by
new Test([test class name]).startTest([test args]);Timeouts used:
Test.WholeTestTimeout - time for the whole test
- Author:
- Alexandre Iline (alexandre.iline@sun.com)
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TestOutTest output.static intStatus returned by test if exception appeared inside scenario.static intPositive test status.protected TimeoutsTest timeouts.static intStatus returned by test if wrong parameter was passed.Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseDown(int status) Throws TestCompletedException exception.protected voiddoSleep(long time) Sleeps.final StringReturns the description value.Get the streams or writers used for print output.Get the timeouts used by thisTest.final ObjectLaunch an action.static voidInvoke thisTest.voidSupposed to be overridden to print a synopsys into test output.static intExecutes a test.static intrun(String[] argv, PrintStream output) Executes a test.static intrun(String[] argv, PrintStream output, PrintStream errput) Executes a test.static intrun(String[] argv, PrintWriter output) Executes a test.static intrun(String[] argv, PrintWriter output, PrintWriter errput) Executes a test.intDefines a way to execute thisTest.voidSet the streams or writers used for print output.voidsetTimeouts(Timeouts timeouts) Set the timeouts used by thisTest.intExecutes test.testForName(String testName) Creates an instance of a class named by the parameter.Methods inherited from class ActionProducer
actionProduced, getException, getFinished, getResult, produceAction, run, setActionPriorityMethods inherited from class Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Field Details
-
WRONG_PARAMETERS_STATUS
public static int WRONG_PARAMETERS_STATUSStatus returned by test if wrong parameter was passed. -
SCENARIO_EXCEPTION_STATUS
public static int SCENARIO_EXCEPTION_STATUSStatus returned by test if exception appeared inside scenario. -
TEST_PASSED_STATUS
public static int TEST_PASSED_STATUSPositive test status. -
timeouts
Test timeouts. -
output
Test output.
-
-
Constructor Details
-
Test
Constructor for tests requiring only a class instance. Creates a subclass ofActionProducerandjava.lang.Threadthat runs in a separate thread of execution and waits for execution to finish. The current output stream assignments and timeouts are used.- Parameters:
testClassName- Full test class name
-
Test
Constructor for scenarios that require an instance and might require an argument. Creates a subclass ofActionProducerandjava.lang.Threadthat runs in a separate thread of execution and waits for execution to finish. The current output stream assignments and timeouts are used.- Parameters:
scenario- a test scenario- See Also:
-
Test
protected Test()No argument constructor. Used by subclasses of thisTestclass. Creates a subclass ofActionProducerandjava.lang.Threadthat runs in a separate thread of execution and waits for execution to finish. The current output stream assignments and timeouts are used.
-
-
Method Details
-
closeDown
public static void closeDown(int status) Throws TestCompletedException exception. The exception thrown contains a pass/fail status and a short statusjava.lang.String. Can by invoked from test to abort test execution.- Parameters:
status- If 0 - test passed, otherwise failed.
-
run
Executes a test.- Parameters:
argv- First element should be a test class name, all others - test args.- Returns:
- test status.
-
run
Executes a test.- Parameters:
argv- First element should be a test class name, all others - test args.output- Stream to put test output and errput into.- Returns:
- test status.
-
run
Executes a test.- Parameters:
argv- First element should be a test class name, all others - test args.output- Stream to put test output into.errput- Stream to put test errput into.- Returns:
- test status.
-
run
Executes a test.- Parameters:
argv- First element should be a test class name, all others - test args.output- Writer to put test output and errput into.- Returns:
- test status.
-
run
Executes a test.- Parameters:
argv- First element should be a test class name, all others - test args.output- Writer to put test output into.errput- Writer to put test errput into.- Returns:
- test status.
-
main
Invoke thisTest. The call might be directly from the command line.- Parameters:
argv- First element should be a test class name, all others - test args.
-
testForName
-
setTimeouts
Set the timeouts used by thisTest.- Specified by:
setTimeoutsin interfaceTimeoutable- Overrides:
setTimeoutsin classActionProducer- Parameters:
timeouts- A collection of timeout assignments.- See Also:
-
getTimeouts
Get the timeouts used by thisTest.- Specified by:
getTimeoutsin interfaceTimeoutable- Overrides:
getTimeoutsin classActionProducer- Returns:
- an object containing information about timeouts.
- See Also:
-
setOutput
Set the streams or writers used for print output.- Specified by:
setOutputin interfaceOutputable- Overrides:
setOutputin classActionProducer- Parameters:
out- An object used to identify both output and error print streams.- See Also:
-
getOutput
Get the streams or writers used for print output.- Specified by:
getOutputin interfaceOutputable- Returns:
- an object containing references to both output and error print streams.
- See Also:
-
startTest
Executes test.- Parameters:
param- Object to be passed into this test's launch(Object) method.- Returns:
- test status.
-
launch
Launch an action. Pass arguments to and execute a testScenario.- Specified by:
launchin interfaceAction- Overrides:
launchin classActionProducer- Parameters:
obj- An argument object that controls test execution. This might be ajava.lang.String[]containing command line arguments.- Returns:
- an Integer containing test status.
- See Also:
-
printSynopsis
public void printSynopsis()Supposed to be overridden to print a synopsys into test output. -
getDescription
Description copied from interface:ActionReturns the description value.- Specified by:
getDescriptionin interfaceAction- Specified by:
getDescriptionin interfaceWaitable- Overrides:
getDescriptionin classActionProducer- Returns:
- this
ActionProducer's description. - See Also:
-
runIt
Defines a way to execute thisTest.- Specified by:
runItin interfaceScenario- Parameters:
param- An object passed to configure the test scenario execution. For example, this parameter might be ajava.lang.String[]object that lists the command line arguments to the Java application corresponding to a test.- Returns:
- an int that tells something about the execution. For, example, a status code.
- See Also:
-
doSleep
protected void doSleep(long time) Sleeps.- Parameters:
time- The sleep time in milliseconds.
-