Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8350098

jpackage test lib erroneously will run methods without @Test annotation as tests

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • 21, 23, 24
    • tools
    • b11
    • generic
    • generic

      If a class has methods with the same name, one is annotated with jdk.jpackage.test.Annotations.Test annotation. Others will also be executed as tests. E.g.:

      class Foo {
          @jdk.jpackage.test.Annotations.Test
          @jdk.jpackage.test.Annotations.Parameter("1")
          public void a(int v) {}

          public void a() {} // jpackage test-lib will consider this method as a test, but it shouldn't
      }

      Another, more likely, way this error occurs is when a parameterized test function has the same name as a function supplying parameters:

      class Foo {
          @Test
          @ParameterSupplier("testDates")
          public void testDates(LocalDate v) {
          }

          // jpackage test-lib will consider this method as a test, but it shouldn't
          public static Collection<Object[]> testDates() {
              return List.of(new Object[][] {
                  { LocalDate.parse("2018-05-05") },
                  { LocalDate.parse("2018-07-11") },
              });
          }
      }

      This error doesn't affect existing tests. It was discovered in not yet integrated tests.

            asemenyuk Alexey Semenyuk
            asemenyuk Alexey Semenyuk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: