Project Properties

Once a new project is defined using the New Project wizard, certain additional settings specific to Unit Test are needed to configure and run your test. This dialog box can also be accessed from the menu: Project -> Properties...

These are the tabs:


This tab is visible only for Server / Web Application.

General Settings

Application Type: Select the type of your web application from: Simple / Struts / Template.

Many Web applications follow a Model-View-Controller (MVC) architecture and use some template-based framework. In such frameworks, the URL being used and displayed is often not the real name of the underlying JSP file. Since AppPerfect Java Unit Test unit tests your application via HTTP URLs, it needs to be able to access the underlying JSP file.

Applications based on the Struts framework are one type of template-based applications for which support is provided out-of-the-box. In the Struts based Server Project, the JSP files can have multiple mapping, which are defined in the Struts Config file. AppPerfect Java Unit Test will read this file for a Struts Based Project and show the mappings available in a drop-down box.

In a Template Based Server Project, the mapping has to be provided manually for each JSP file that has been mapped. Unlike a Struts Based project, a Template Based project relies on unique mappings for the JSP files which have to be provided manually in the Mapped File Name text field of the Generate Test Classes dialog box. Simple Server Project is the one where there is no mapping provided for JSP files. The name with the JSP file sits on the server, is the same that appears in the browser window to the user.

Unit Test searches for the XML Struts Config file for Struts Based Project types and then shows you the corresponding mappings for the JSP file for which you are generating Test Cases. Since there are multiple mappings associated with a single JSP file, you have to select the appropriate mapped file name from the drop-down box.

Document Root : Here you need to specify the document root for your web application. It is the root of your web application containing "WEB-INF" folder.

EJB Settings

If your application is an EJB application, and you wish to perform an "in-container" unit test of your application, specify the necessary values. "In container" testing means your classes will be executed in your app server and perform all operations exactly as it would in a production environment. This is different from regular unit testing, where all classes are individually tested in a new JVM instance.

Test Case Generation

Scope-based filtering: You can choose the scope for unit testing by selecting, deselecting Public, Protected, Package and Private check boxes. Only methods that match the specified scope will be unit tested. It is generally a good idea to start with one scope type and then expand unit testing to others.

Import test classes (If found in the source path provided): Enable this option if you already have unit test cases for your source and they are present in the source path provided. AppPerfect Java Unit Test will take care of automatically importing those test classes and showing them in Test Classes tab in the UI.

Generate test cases which passes null values to methods: While it is always a good idea to test for null values, most users find it generates too many errors and so wish to do it later on in the project, not to begin with.

Generate test case for finding uncaught exceptions: This option should be used if you want to generate test cases to find unique uncaught exceptions in your code. Its possible that your method may not be expecting certain input and hence this may generate some flase results but overall its good idea to find uncaught exceptions in the code.

Limit number of test cases generated per method: If number of test cases per method are not restricted then product may generate 100's of test cases per method based on complexity and number of input parameters of the method. Usually this option should be turned off unless you know for sure that some methods of your classes are going to result in 100's of test cases.

Limit number of objects per source class to: Enable this option to limit number of unique instances created for a source class. AppPerfect Java Unit Test looks for static methods returning object of class, constructors of class, static fields returning object of class and adds all the found ways to object repository.

Limit depth of object creation to: Enable this option to limit depth to which AppPerfect Unit Test should resolve the constructors. AppPerfect resolves the constructors recursively till the depth or till it finds default no parameter constructor or constructor with primitive parameters. Usually its good idea to limit this depth to some low value like 1 or 2 to reduce the number of test cases generated by tool.

Preserve user changes while re-generating test classes: Enable this option if you want to preserve the changes done by you in the generated test classes. If this option is off then Unit Test will either delete all user changes. While preserving user changes if Unit Test finds that because of those changes the test classes are not in compilable state then it can either comment those changes or can delete those changes based on setting done.

Generate test cases with stubs: Some times you may want to execute some other piece of code in place of actual class/method like if you are trying to get a connection or trying to execute a query to get resultset but actual database is not present in that case you can create stubs to execute some dummy code in place of Statement.Execute Query and return some dummy resultset. This feature is very useful for test driven development as using this feature you can simulate the behavior of application and then later when actual code is ready can inform user not to use stubs.

JDBC Expert: Use this feature if your application depends on database and same is not available during testing. When an application uses JDBC, Java Unit Test provides different ways to configure mock objects in order to adequately unit test the code that uses databases. You should use this feature to not corrupt / mess your actual database during unit testing.

Test Case Execution

AppPerfect Java Unit Test generates test classes from your source files / JSPs and executes them in an intermediary step. These are dummy test classes. After execution of the dummy test classes, Unit Test picks the test cases which provide maximum code coverage and these are the test classes you can see in the Test Classes tab in your project.

Working Folder: This is the folder from where the test classes will be executed. This is useful if you are using relative paths in your application to load files. By default its same as the project's home folder.

Time Out if test class does not complete execution in (sec.): Provide a time out value here.

Collect Memory Leak Information: If specified, AppPerfect will detect memory leaks in your code. The way it works is a GC is performed before a test class starts and another GC is performed after the case class execution is complete. Any additional objects created during that test case execution that were not cleaned up by the second GC are reported as memory leaks.

Report assertion failures:You can choose to report assertion failures. Select this check box. This is useful if you are aware of the assertion failures your project is likely to throw and want to include them in the results.

Report exception failures:You can choose to report exception failures. Select this check box. This is useful if you want to know what all exceptions are getting thrown from your application. You can filter certain exceptions if you don't want them to be reported.

Run each test class in a separate process: You can choose to run each test class in separate JVM. This is very resource intensive and time consuming process so should not be turned on unless required.

Additional Settings

Additional Settings are provided in Tools -> Options... -> Java Unit Test.