Cedric,
Based on your inputs that TestNG is capable of invoking protected
methods, I decided to run a quick check and I found something which I
thought I would clarify with you.
If a class has a mixture of protected and public TestNG annotated
methods then TestNG seems to invoke all of them, but if a class has
only protected methods then TestNG doesnt invoke them. Why is it so ?
To elaborate, here's a sample :
//Both test methods are invoked
public class TestNGExploration {
@Test
protected void foo() {
System.out.println("Protected Method says hi");
}
@Test
public void bar() {
System.out.println("Public Method says hi");
}
}
Output :
Public Method says hi
Protected Method says hi
PASSED: bar
PASSED: foo
===============================================
Default test
Tests run: 2, Failures: 0, Skips: 0
===============================================
//Nothing is invoked
public class TestNGExploration {
@Test
protected void foo() {
System.out.println("Protected Method says hi");
}
@Test
protected void bar() {
System.out.println("Another Protected Method says hi");
}
}
Output :
===============================================
Default test
Tests run: 0, Failures: 0, Skips: 0
===============================================
-Krishnan
On Feb 7, 11:32 pm, Krishnan Mahadevan