-
Notifications
You must be signed in to change notification settings - Fork 5
Use TestNG API #1
Comments
TestNG doesn't provide an api for test discovery. Instead, we use the suite file and TestNG will find tests accordingly to the suite.
This part should not be a problem. |
Is there a way to inspect such suite files and list all tests that will be executed w/o executing them? How is a TestNG suite file passed to the TestNG runtime? Via an explicit option? Does TestNG scan the current directory for suite files?
No, it is up to the engine implementation to tell the Platform which tests it is able to execute -- based on the selectors the user (of the Platform, read: build tool) passed. I implemented the handling of 3 selectors in testng-junit5/src/main/java/org/testng/junit5/DiscoveryHelper.java Lines 27 to 53 in 78eb11d
The interesting part is the Each |
The later part sounds promising. Copied from http://beust.com/weblog/2004/09/01/announcing-testng-1-0/ The Surefire TestNG Provider does something similar: |
Current iteration already uses testng-junit5/src/main/java/org/testng/junit5/TestNGine.java Lines 73 to 85 in 1655fc0
|
@juherr Anything we can improve here? |
I'm really sorry, I didn't take the time to have a look on it. But I don't forget it! |
@sormuras Any advice to run tests in debug mode from IDE? Running a simple test in IntelliJ package org.testng.junit5;
import org.testng.Assert;
import org.testng.annotations.Test;
public class TestNGTest {
@Test
void test() {
Assert.assertNull(null);
}
} produces
And I don't find how to force JUnit5 runner in IntelliJ. Any idea? |
Afaik, an annotation has to be meta-annotated with
Mh, isn't TestNG supported by IDEA? Or do you need a plugin? Strange, that the JUnit 3/4 Starter kicks in... |
Ok, I will try with TestNG is supported by IDEA which runs the TestNG plugin. That's why I force a JUnit runner on the TestNG class which runs JUnit 4 by default. |
If you annotate your |
I agree with Anna. Why do you want to IDE execute your TestNG tests as JUnit 5 tests? |
I'm just trying to find the easier way to use the debugger from the IDE. |
Ah, I see. Mh... give me second. It should work best within this very project. |
Here we go on Travis CI: https://travis-ci.com/testng-team/testng-junit5/jobs/172970155#L694 With a break point set in IDEA ...leads to a halt while debugging: |
fyi, I added This is due to using |
@juherr Does it work on your box now too? |
@sormuras Yes, it is working. Thank! |
You're welcome! |
The discovery and execution is implemented in very raw way.
TestNG
API should be used to discover test classes and test methods to createTestDescriptor
s.TestNG
API should be used to execute test methods and report the result accordingly.The text was updated successfully, but these errors were encountered: