rspec/rules/S5395/apex/rule.adoc

36 lines
970 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
``++SeeAllData=true++`` should not be used because it gives your tests access to all data in your organization. Activating this option makes your test dependent on existing data and more difficult to maintain. Tests should create their own data.
This rule raises an issue when it sees ``++@isTest(SeeAllData=true)++``.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,apex]
2021-04-28 16:49:39 +02:00
----
@isTest(SeeAllData=true) // Noncompliant
public class MyTestClass {
@isTest(SeeAllData=true) // Noncompliant
static void myTestMethod() {
// Can access all data in the organization.
}
}
----
== Resources
2021-04-28 16:49:39 +02:00
* https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_seealldata_using.htm[Salesforce documentation - Using the isTest(SeeAllData=True) Annotation]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
endif::env-github,rspecator-view[]