Creating a Unit Test case for code
In this recipe, we will create a test case for the ConWHSVehicleGroupChange
class, where we will test each part of this class. This includes when it should fail and when it should succeed. The process will involve programmatically creating some test data in order to perform the update.
Getting ready
We will just need the unit test project, which we created in the previous recipe, open. Also, on the main menu, select X64
from Test
| Test Setting
| Default Processor Architecture
.
How to do it...
To create the unit test class, follow these steps:
- Create a new class and name it
ConWHSVehicleGroupChangeTest
. The suffix is important. - In the code editor, change the declaration so that it extends
SysTestCase
. - Next, we will need some constants for test cases that we either expect to succeed or fail; in this case, we will have the following:
const ConWHSVehicleGroupId groupId= '%VG01%'; const ConWHSVehicleId vehicleId ='%V001%'; const str notFound= '%ERROR%';
- The next...