mardi 1 mars 2016

Weird behaviour in TestNG with dependencies - no error raised

I have made a stupid typographical mistake while defining one of my tests. I have accidentally written the annotation like so:

@Test(dependsOnMethods = {"method1, method2"}, alwaysRun = true)

Do you see the error? I sure didn't (since the real method names are also much longer), and it made me waste almost 2 hours because TestNG offers no help regarding this.

Why it offers no help: As a result of this mistake, no error was raised, everything compiled fine, but when my suite was about the run it just skipped all the tests without any indication why:

__PLAN___
Total tests run: 0, Failures: 0, Skips: 0

There is also no place in the logs/xmls to show that something might be wrong.

Only after a long while I noticed that I meant to write:

@Test(dependsOnMethods = {"method1", "method2"}, alwaysRun = true) 

Meaning that the test actually depends on 2 methods except one long one which obviously didn't exist.

I am now trying to add to our framework the option to alert the user of such mistake so it won't happen to any more people (we are a big company).

Question: Where could I find, in the TestNG's code perhaps, the code/documentation that will allow me to grab the event where TestNG fails, and act upon it? There has to be some place in there where TestNG checks the suite and decides to not run the test because of this problem...

Aucun commentaire:

Enregistrer un commentaire