1

My goal is to have a class which can find any tests written in kotlintest. I already have working code for Java/Scala/Groovy unit tests but can't get it to work for Kotlintest.

My discover code:

LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(selectPackage("com.example")).build();
descriptor = new KotlinTestEngine().discover(request, uniqueId);

UniqueId has value of "engine:junit-example". I tried adding the following code but it doesn't work either.

new DiscoverySelectorResolver().resolveSelectors(discoveryRequest, descriptor);

The descriptor contains all the classes with tests but no test methods. In other cases it is enough to call descriptor.getChildren() to get the test methods but with Kotlintest I get empty list.

Thanks for any help.

lsrom
  • 608
  • 8
  • 22
  • I guess we need to see more code in order to help. It’s not clear to me if you want to write a KotlinTestEngine or use an existing one. Since a test engine usually creates test descriptors by looking at the tests themselves we would also need to see those. – johanneslink Oct 13 '18 at 04:44
  • There's not a lot of code so far... I need to get list of test methods from the test engine. Now it only gives me classes but I need the methods themselves. – lsrom Oct 15 '18 at 08:54
  • Maybe there are no valid test methods (in the eyes of KotlinTest). But we can only find out if you show the code you use in your experiments. – johanneslink Oct 15 '18 at 12:38

1 Answers1

1

The reason your code doesn't work is because KotlinTest doesn't honour package name selectors. This could be considered a bug in KotlinTest.

It does honour classpath, class, directory and uri selectors though.

Edit:

As of 3.2 KotlinTest now supports package selectors so your code will work.

sksamuel
  • 16,154
  • 8
  • 60
  • 108