Skip to content

Setup integration tests pipeline #41

@rdiachenko

Description

@rdiachenko

We need a way to avoid putting manually generated Checkstyle reports and configs while testing recipes. Ideally we should have InputXXX and OutputXXX java files only and a simple test class for a recipe. Thus, we need to setup a pipeline for integraiton test, which will include running Checkstyle, getting violations, passing config and violations to the recipe, running the recipe and verifying the output from the recipe matches expected OuputXXX.

The concept is as follows.

  • Add Checkstyle dependency with a tests qualifier under the test scope
  • Take one recipe and create InputXXX for it following Checkstyle format, which means the InputXXX starts with the check's config
  • Check how AbstractXmlTestSupport class works. We can create AbstractRecipeTestSupport class that will extend AbstractXmlTestSupport and have these methods:
abstract getSubpackage(); // subpackage for input files

verify(InputXXX) { // main method that executes pipeline
  // create check based on inline config in InputXXX
  // register XML logger
  // run the check
  // take config and xml report from the check's run and initialise main CheckstyleAutoFix recipe
  // preprocess InputXXX by renaming it to OutputXXX
  // run CheckstyleAutoFix
  // postprocess OutputXXX by removing "// violation" comments
  // verify that obtained OutputXXX matches expected OutputXXX
}
  • Every recipe test should extend AbstractRecipeTestSupport and look like this:
class UpperEllTest extends AbstractRecipeTestSupport {
  String getSubpackage() { return "upperell"; }

  @Test test1() { verify("UpperEllWithXXX"); }

  @Test test2() { verify("UpperEllWithYYY"); }
}
  • Update all current tests and remove redundant report and config files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions