rspec/rules/S2699/apex/rule.adoc

57 lines
1.1 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:48:07 +02:00
A test case without assertions ensures only that no exceptions are thrown. Beyond basic runnability, it ensures nothing about the behavior of the code under test.
2021-02-02 15:02:10 +01:00
2020-06-30 12:48:07 +02:00
 
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
This rule raises an issue when a function with an ``++@isTest++`` annotation does not call at least one of the following functions once:
2021-01-27 13:42:22 +01:00
* ``++System.assert++``
* ``++System.assertEquals++``
* ``++System.assertNotEquals++``
2020-06-30 12:48:07 +02:00
=== Noncompliant code example
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,apex]
2020-06-30 12:48:07 +02:00
----
@isTest()
class ApexTests {
@isTest
private static void mytest() { // Noncompliant
MyClass.createTask();
}
}
----
=== Compliant solution
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,apex]
2020-06-30 12:48:07 +02:00
----
@isTest()
class ApexTests {
@isTest
private static void mytest() {
Task task = MyClass.createTask();
System.assert("expected subject", task.subject, "task has not the expected subject");
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]