Skip to content

Commit

Permalink
[apex] Update tests (ApexUnitTestClassShouldHaveAsserts, ApexAssertio…
Browse files Browse the repository at this point in the history
…nsShouldIncludeMessage) #4097
  • Loading branch information
adangel committed Aug 29, 2022
1 parent 29c4e99 commit 7c6277c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
Expand Up @@ -116,4 +116,72 @@ public class Foo {
}
]]></code>
</test-code>

<test-code>
<description>[apex] Support new Assert class (Apex v56.0) - negative test case #4097</description>
<expected-problems>9</expected-problems>
<expected-linenumbers>6,12,19,28,34,40,46,52,58</expected-linenumbers>
<code><![CDATA[
@isTest
public class Foo {
@isTest
static void testAreEqual() {
String sub = 'abcde'.substring(2);
Assert.areEqual('cde', sub);
}
@isTest
static void testAreNotEqual() {
String sub = 'abcde'.substring(2);
Assert.areNotEqual('xyz', sub);
}
@isTest
static void testFail() {
try {
SomeClass.methodUnderTest();
Assert.fail();
} catch (DmlException ex) {
// Add assertions here about the expected exception
}
}
@isTest
static void testIsFalse() {
Boolean containsCode = 'Salesforce'.contains('code');
Assert.isFalse(containsCode);
}
@isTest
static void testIsInstanceOf() {
Account o = new Account();
Assert.isInstanceOfType(o, Account.class);
}
@isTest
static void testIsNotInstanceOf() {
Contact con = new Contact();
Assert.isNotInstanceOfType(con, Account.class);
}
@isTest
static void testIsNotNull() {
String myString = 'value';
Assert.isNotNull(myString);
}
@isTest
static void testIsNull() {
String myString = null;
Assert.isNull(myString);
}
@isTest
static void testIsTrue() {
Boolean containsForce = 'Salesforce'.contains('force');
Assert.isTrue(containsForce);
}
}
]]></code>
</test-code>
</test-data>
Expand Up @@ -76,13 +76,13 @@ private class C2_Assignment_Report_Job_Test {

<test-code>
<description>#1089 [apex] ApexUnitTestClassShouldHaveAsserts: Verify use of additionalAssertMethodPattern, positive test</description>
<rule-property name="additionalAssertMethodPattern">(Assert\.\w+|verify\w+)</rule-property>
<rule-property name="additionalAssertMethodPattern">(MyAssert\.\w+|verify\w+)</rule-property>
<expected-problems>0</expected-problems>
<code><![CDATA[
@isTest
public class Foo {
public static testMethod void testAssertIsTrue() {
Assert.isTrue(someCondition);
MyAssert.isTrue(someCondition);
}
public static testMethod void testLocalVerify() {
Expand Down

0 comments on commit 7c6277c

Please sign in to comment.