Run unit tests

Completed

Large projects can have multiple developers who are creating code in their own environments. Before pushing code changes to production, unit tests should be performed to verify the code. Unit tests must follow specific syntax. The class must extend the SysTestCase class. Test methods must be public, cannot have parameters, must return void, and need to be decorated with the SysTestMethod.

The test method can include other methods that do not follow these rules. Test methods typically have three distinct methods: arrange, act, and assert. The arrange method sets up all the variables. The act method does some processing. The assert method verifies if the result is expected. You can use the setup() method that is built into the framework to arrange the variables that will be used throughout the test methods. For example, if you have a variable currencyAmt that is used in multiple test methods, instead of creating a variable for currencyAmt in each test method, you would only need to create it in the setup() method.

You can choose from several different assert methods to verify the test. AssertEquals() is the most common, but other methods are available, such as assertTrue() and assertNotNull(). You can also use the code this.parmExceptionExpected(true) to assert that an error thrown is the correct behavior.

After the test class is created, you can right-click the class and select Run tests. This selection will open the unit test toolbar. Using unit tests can be a fast and reliable way to develop code. Over time, you will build new tests as new functionality is added. This allows you to quickly run these unit tests to make sure that everything works as expected. For information, see SysTest Filtering using class and method attributes.

Screenshot of the Visual studio run tests option.