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

New rule: AvoidMixingJunit4AndJunit5 #147

Open
dgroup opened this issue May 19, 2022 · 0 comments
Open

New rule: AvoidMixingJunit4AndJunit5 #147

dgroup opened this issue May 19, 2022 · 0 comments
Assignees
Labels

Comments

@dgroup
Copy link
Owner

dgroup commented May 19, 2022

Summary

Key Value
Rule AvoidMixingJunit4AndJunit5
Ruleset io/github/dgroup/arch4u/pmd/testing/junit.xml
Category Error Prone
Framework junit
Since TBD
Incidents in past at my experience 4+
Template false

Rule definition

<rule name="..."
      since="0.2.0"
      language="java"
      externalInfoUrl="https://github.com/dgroup/arch4u-pmd/discussions/..."
      message="...: https://github.com/dgroup/arch4u-pmd/discussions/..."
      class="io.github.dgroup.arch4u.pmd....">
    <priority>3</priority>
    <properties>
      <property name="..." delimiter="|" value="...|...|...|..."/>
      <property name="..." value="...|..."/>
    </properties>
</rule>

Why?

...

@org.junit.jupiter.api.extension.ExtendWith(Xxx.class) // junit5 class
class MyTest {

    @org.junit.Test // junit4 class, violation
    public void justTestIt(){
         ...
    }
    
}

This approach might be useful:

  1. By XPath detect junit5 classes
    and by regexp XPath detect junit4 classes
//Name[starts-with(@Image, 'org.junit.')] and //Name[starts-with(@Image, 'org.junit.jupiter.')]

String expr = "//*[regexp:test(@id, 'sometext[0-9]+_text')]";
driver.findElement(By.xpath(expr));
@dgroup dgroup self-assigned this May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant