Chapter 9 Generating Persistent Objects for Java and JSF Pages


Run Unit Tests

There are two ways you can run unit tests generated. One is running Ant task. The other is running them in Eclipse.

Running Unit Tests with Ant

To generate the Ant build.xml file, you need to select the Generate Ant build.xml file in the Java code generation options tab.

To use Ant, you need to:

Steps To run unit tests with Ant from PowerDesigner:

  1. Select the Run unit tests task when generating code.

Steps To run unit tests with Ant from the command line:

  1. You can also run the task from command line.
  2. Open a command line window.
  3. Go to the directory where you have generated the code.
  4. Run the JUnit test task by issuing command: Ant junit
  5. Check the output result in ejb3-persistence.log and testout directory.

Running Unit Test in Eclipse

To use Eclipse, you need to download the Eclipse SDK from www.eclipse.org and install it.

If you have selected the Generate Eclipse project artifacts generation option, you can import the generated project into Eclipse and use Eclipse to modify, compile and run the tests.

If you use the PowerDesigner Eclipse plugin, after the code generation, the project is automatically imported or refreshed in Eclipse.

You can run a single test case each time or run them as suite.

Steps To run a single test case:

  1. Open the Java perspective
  2. In the Package Navigator, expand the test package
  3. Select a test case class, for example CustomerTest.java and run it as Unit Test
  4. Select the JUnit view to verify the result:

Steps To run the test suite:

  1. Select AllTests class under test package.
  2. Run it as Application. All the tests will be run as suite.

 


Copyright (C) 2006. Sybase Inc. All rights reserved.