Extension SDK 10.1.2

oracle.jdeveloper.junit
Class TestFactory

java.lang.Object
  extended byoracle.jdeveloper.junit.TestFactory

public class TestFactory
extends java.lang.Object

The TestFactory class is the main entry point for JUnit api users. The Factory is used to create instances of TestSuite, TestCase and TestFixture. The containment hierarchy is very simple.

1. A TestSuite contains a collection of TestCases
2. A TestCase uses a collection of TestFixtures

The responsabilities are as follows:

1. A TestSuite generates the runtime class that runs the tests
2. A TestCase installs itself to a TestSuite
3. A TestFixture installs itself to a TestCase and also configures the project
to be able to run test cases that use the fixture.


Constructor Summary
TestFactory()
           
 
Method Summary
static TestCase createClassTestCase(JProject project, java.lang.String sPackage, java.lang.String sClassName)
          Creates an instance of a ClassTestCase.
static TestCase createMethodTestCase(JProject project, java.lang.String sPackage, java.lang.String sClassName)
          Creates a method test case.
static SuiteTestCase createSuiteTestCase(JProject project, java.lang.String sPackage, java.lang.String sClassName)
          Creates a suite test case.
static TestCase createTestCaseFromClass(JProject project, JotClass testClass)
          This method creates a TestCase from an existing Java class.
static TestFixture createTestFixture(JProject project, java.lang.String sPackage, java.lang.String sClassName)
          Create a new TestFixture and adds a setUp and tearDown methods to it.
static TestFixture createTestFixtureFromClass(JProject project, JotClass fixtureClass)
          This method creates a TestFixture from an existing Java class.
static TestSuite createTestSuite(JProject project, java.lang.String sPackage, java.lang.String sClassName)
          This method is used to create a New TestSuite.
static boolean installJUnit(JProject project)
          This method should be called by any addin\wizard to make sure that JUnit has been downloaded and installed so that JDeveloper can make use of it's functionality.
protected static java.util.HashMap saveProjectState(JProject proj)
           
protected static void sendChangeNotifications(JProject proj, java.util.HashMap map)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestFactory

public TestFactory()
Method Detail

createTestSuite

public static TestSuite createTestSuite(JProject project,
                                        java.lang.String sPackage,
                                        java.lang.String sClassName)
                                 throws java.lang.Exception
This method is used to create a New TestSuite. The new TestSuite class is automatically added to the project. It will be placed in the provided package. The proper imports and suite() method will be generated. You can then use the TestFactory to create test cases and add them to this suite.

Throws:
java.lang.Exception

createClassTestCase

public static TestCase createClassTestCase(JProject project,
                                           java.lang.String sPackage,
                                           java.lang.String sClassName)
                                    throws java.lang.Exception
Creates an instance of a ClassTestCase. This type of testCase adds itself to a TestSuite by passing the test class' name to the addTestSuite() method. The set of test methods is retrieved via introspection. All methods that start with 'test' will be excuted.

Throws:
java.lang.Exception

createMethodTestCase

public static TestCase createMethodTestCase(JProject project,
                                            java.lang.String sPackage,
                                            java.lang.String sClassName)
                                     throws java.lang.Exception
Creates a method test case. This type of test case runs a single method as it's test run. The method is passed in to its constructor.

Throws:
java.lang.Exception

createSuiteTestCase

public static SuiteTestCase createSuiteTestCase(JProject project,
                                                java.lang.String sPackage,
                                                java.lang.String sClassName)
                                         throws java.lang.Exception
Creates a suite test case. This is a test case that implements the suite() method. This type of test case is used as a grouping mechanism for sets of tests.

Throws:
java.lang.Exception

createTestCaseFromClass

public static TestCase createTestCaseFromClass(JProject project,
                                               JotClass testClass)
This method creates a TestCase from an existing Java class. It's basically a way to construct a TestCase from any TestCase derived classes. It's not required that source code be present, the class can come from any provided .class files in the class path.


createTestFixtureFromClass

public static TestFixture createTestFixtureFromClass(JProject project,
                                                     JotClass fixtureClass)
This method creates a TestFixture from an existing Java class. It's basically a way to construct a TestFixture from any class. It's not required that source code be present, the class can come from any provided .class files in the class path.


createTestFixture

public static TestFixture createTestFixture(JProject project,
                                            java.lang.String sPackage,
                                            java.lang.String sClassName)
                                     throws java.lang.Exception
Create a new TestFixture and adds a setUp and tearDown methods to it. The TestFixture may be further customized and installed into a TestCase. The same instance of a TestFixture may be installed into a number of TestCases. It's not required to create a new TestFixture every time you add it to a TestCase. The TestFixture is simply a code generator for the actual runtime fixture.

Throws:
java.lang.Exception

installJUnit

public static boolean installJUnit(JProject project)
This method should be called by any addin\wizard to make sure that JUnit has been downloaded and installed so that JDeveloper can make use of it's functionality.


saveProjectState

protected static java.util.HashMap saveProjectState(JProject proj)

sendChangeNotifications

protected static void sendChangeNotifications(JProject proj,
                                              java.util.HashMap map)

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.