Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apex] ApexAssertionsShouldIncludeMessage and ApexUnitTestClassShouldHaveAsserts: support new Assert class (introduced with Apex v56.0) #4096

Closed
tprouvot opened this issue Aug 17, 2022 · 1 comment · Fixed by #4097
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@tprouvot
Copy link
Contributor

tprouvot commented Aug 17, 2022

Affects PMD Version:
all

Rules:

Description:
With the Winter 23' release, a new class can be used to perform assertion in test class.
We have to add the new methods to existing rule to avoid false positive when this class will be used.

Apex class Assert
Code Sample demonstrating the issue:

@isTest
public with sharing class Test {

	@isTest
	public static void testAssert(){
		String sub = 'abcde'.substring(2);
		Assert.areEqual('cde', sub, 'Expected characters after first two');
	}
}

Expected outcome:

PMD reports a violation at line ..., but that's wrong. That's a false positive.
image

Running PMD through: [VS Code]

@tprouvot tprouvot added the a:false-positive PMD flags a piece of code that is not problematic label Aug 17, 2022
@tprouvot
Copy link
Contributor Author

Hi guys @adangel @rsoesemann @SCWells72,
I would be more than happy to contribute to the Apex PMD plugin, this is my first PR on this repo so feel free to add comments or suggestions !

@adangel adangel changed the title [apex] api 56.0 ApexAssertionsShouldIncludeMessage and new apex class : Assert [apex] ApexAssertionsShouldIncludeMessage: support new Assert class (introduced with Apex v56) Aug 24, 2022
@adangel adangel changed the title [apex] ApexAssertionsShouldIncludeMessage: support new Assert class (introduced with Apex v56) [apex] ApexAssertionsShouldIncludeMessage - support new Assert class (introduced with Apex v56) Aug 24, 2022
@adangel adangel changed the title [apex] ApexAssertionsShouldIncludeMessage - support new Assert class (introduced with Apex v56) [apex] ApexAssertionsShouldIncludeMessage: support new Assert class (introduced with Apex v56.0) Aug 24, 2022
@adangel adangel added this to the 6.49.0 milestone Aug 29, 2022
@adangel adangel changed the title [apex] ApexAssertionsShouldIncludeMessage: support new Assert class (introduced with Apex v56.0) [apex] ApexAssertionsShouldIncludeMessage and ApexAssertionsShouldIncludeMessage: support new Assert class (introduced with Apex v56.0) Aug 29, 2022
@adangel adangel changed the title [apex] ApexAssertionsShouldIncludeMessage and ApexAssertionsShouldIncludeMessage: support new Assert class (introduced with Apex v56.0) [apex] ApexAssertionsShouldIncludeMessage and ApexUnitTestClassShouldHaveAsserts: support new Assert class (introduced with Apex v56.0) Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants