Showing 1 of 1 total issue
Apex unit test classes should have at least one System.assert() or assertEquals() or AssertNotEquals() call Open
Open
static void testVirtualMethods() {
- Read upRead up
- Exclude checks
ApexUnitTestClassShouldHaveAsserts
Since: PMD 5.5.1
Priority: Medium
Categories: Bug Risk
Remediation Points: 5000000
Apex unit tests should include at least one assertion. This makes the tests more robust, and using assert with messages provide the developer a clearer idea of what the test does.
Example:
@isTest
public class Foo {
public static testMethod void testSomething() {
Account a = null;
// This is better than having a NullPointerException
// System.assertNotEquals(a, null, 'account not found');
a.toString();
}
}