Component testing and the Java editor
After you create a test or stub, you can use the Java editor to edit both the test behavior code and the stub user code class that is generated along with the stub.
Editing test behavior code
To edit the test behavior code, simply right-click in the Java editor and click Component Test to display a menu of elements you can add to the code. These elements include initialization points, validation actions, timers and timer validations, fail actions, and error actions. You can also start up a wizard that leads you through the process of inserting additional methods and constructors to the test behavior code.
Editing stub user code
When you create a stub, you can define stub data in the stub data table, and you can also edit the stub user code that is generated along with the stub. Typically, you would define stub behavior in the user code class in cases where the behavior cannot be performed in the stub data table. For example:
- You need to perform tasks to set the external state so tests can be executed in the proper context.
- A method needs to perform a function that is not data related, such as creating a file.
- The values to be returned cannot be defined in the stub data table because the values rely on an external file or database.
- You need to specify stub behavior based on conditions other than the input values.
Related concepts
Stub behavior
Related tasks
Inserting initialization points
Inserting validation actions
Inserting timing constraints