Skip to content

[test] Improve xml test schema #3302

@oowekyala

Description

@oowekyala

Is your feature request related to a problem? Please describe.
Currently there's a few things that are not so great with the test schema

  1. the only way to ignore a test is to set the attribute regressionTest to false, which is... weird
  2. there's no way to execute a single test ("focus" a test). Some IDEs may provide this facility (eclipse), but some don't (intellij), and having an ide-independent way to do this would be nice
  3. the attribute reinitializeRule of test-code is useless. I can't see a reason not to reinitialize the rule.
  4. we could remove the pattern from the source-type element, as we do the validation at runtime anyway. This means we wouldn't have to update the schema when we add/remove languages, which makes pmd easier to extend
  5. validation of consistency between expected-problems, expected-messages and expected-linenumbers is buggy. Sometimes it throws a validation error, sometimes it's silent. For instance
         <expected-problems>0</expected-problems>
         <expected-messages>
             <message>1</message>
         </expected-messages>

throws a validation error, but the following doesn't

      <expected-problems>1</expected-problems>
      <expected-linenumbers>1,2,3</expected-linenumbers>
      <expected-messages>
          <message>1</message>
      </expected-messages>

Describe the solution you'd like Update the schema and its parser to support focus and disabled attributes, deprecate useless things

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Some other things that we should keep in mind and fix later:

  1. the <rule-property> element has ad-hoc syntax, instead of just reusing the syntax for <property> that's from the ruleset schema. This will be awkward when the XSD for rulesets is updated ([core] Implementation plan for property framework changes #1432)
  2. the useAuxClasspath attribute doesn't look useful. Related to [java] Improve rule tests with auxclasspath #2649

Metadata

Metadata

Assignees

Labels

an:enhancementAn improvement on existing features / rulesin:testingAbout tests of pmd, eg the module pmd-lang-test or pmd-test [test]

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions