Creating the object

Once you have specified the field values that are important to the test, you must create the object. Typically, this is done using the test data builder's create method. For example, in the following code, the fourth line creates the object.

gw.transaction.Transaction.runWithNewBundle( \ bundleObj -> {
	var testUser = new UserContactBuilder()
	    .withFirstName("Tom")
	    .create(bundleObj)
} , "su" )

Which bundle is the object created in

The create method has multiple signatures. One of them is:

create(bundleObj)

This signature creates the object in the specified bundle. For test objects, Guidewire recommends using this signature, as it gives you the ability to create the object in the bundle managed by runWithNewBundle. This bundle is inherently committed at the end of the block.

There is another signature:

create()

This signature creates the object in the default bundle. The default bundle is a bundle that typically exists by default. When objects are created without a specified bundle, they are created in the default bundle.

For test objects, Guidewire does not recommend using this signature. The default bundle is not inherently committed at the end of the runWithNewBundle block. If you create objects in the default bundle, you must also manually commit that bundle. Also, if other processes have added objects to the default bundle, committing the bundle can lean to unexpected behaviors.