== Why is this an issue?

Asserts should only be used in test code. Salesforce provide better ways to handle errors:

* https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_exceptions.htm[Trigger Exceptions]
* https://developer.salesforce.com/blogs/2017/09/error-handling-best-practices-lightning-apex.html[Error Handling Best Practices for Lightning and Apex]

Classes containing test code, including test helper methods, should always have the ``++@isTest++`` annotation. There is a https://help.salesforce.com/articleView?id=000314162&language=en_US&type=1&mode=1[limit to the amount of code] an organization can upload into Salesforce. Test code does not count towards this limit, and test code is recognized via the ``++@isTest++`` annotation.


This rule raises an issue when methods ``++System.assert++``, ``++System.assertEquals++`` or ``++System.assertNotEquals++`` are called in a class which is not annotated with ``++@isTest++``.


=== Noncompliant code example

[source,apex]
----
class ApexTests {
    private static void testHelper(Task task) {
        System.assert("expected subject", task.subject, "task has not the expected subject");  // Noncompliant
    }
}
----


=== Compliant solution

[source,apex]
----
@isTest
class ApexTests {
    private static void testHelper(Task task) {
        System.assert("expected subject", task.subject, "task has not the expected subject");
    }
}
----


== Resources

* https://help.salesforce.com/articleView?id=000314162&language=en_US&type=1&mode=1[Increase Apex code character limit]
* https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_utility_classes.htm[Common Test Utility Classes for Test Data Creation]


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Either annotate the class with "@isTest" or remove this assert statement.


=== Highlighting

``++System.assert++``, ``++System.assertEquals++`` and ``++System.assertNotEquals++`` statements


endif::env-github,rspecator-view[]
