Class TestRecorderSuperClassCandidateScanner

java.lang.Object
com.vaadin.copilot.testrecordergenerator.TestRecorderSuperClassCandidateScanner

public class TestRecorderSuperClassCandidateScanner extends Object
Finds the custom base classes used by recorded tests. By default it looks for TestBench tests (methods annotated with @BrowserTest in classes extending BrowserTestBase). It can also be configured for other test types, e.g. Browserless tests. Important note: This class does a heavy work, so methods should run in async
  • Constructor Details

    • TestRecorderSuperClassCandidateScanner

      public TestRecorderSuperClassCandidateScanner()
      Creates a scanner for TestBench tests.
    • TestRecorderSuperClassCandidateScanner

      public TestRecorderSuperClassCandidateScanner(Set<String> rootTypes, String testAnnotation, String defaultSuperClass, boolean acceptUnresolvedSuperClasses)
      Creates a scanner for the given root types.
      Parameters:
      rootTypes - fully qualified names of the base types a candidate must extend
      testAnnotation - simple name of the annotation that marks test methods
      defaultSuperClass - the class appended last to the candidates
      acceptUnresolvedSuperClasses - whether a superclass whose source is not in the project is accepted as a candidate
  • Method Details

    • scan

      public Map<String,Integer> scan() throws IOException
      Scans the test source folder for tests of the configured type and counts the custom superclasses they use.
      Returns:
      fully qualified superclass names and the number of tests using each one
      Throws:
      IOException - if the test source folder cannot be read
    • getCandidatesInOrder

      public List<String> getCandidatesInOrder() throws IOException
      Gets all candidate superclasses ordered by how often recorded tests use them. Candidates with the same count are ordered by class name. BrowserTestBase is added as the last, fallback superclass.
      Returns:
      fully qualified candidate superclass names, most frequently used first
      Throws:
      IOException - if the test source folder cannot be read