zara
zara

Reputation: 99

Shouldn't @Test with "alwaysRun=true" run irrespective of methods or groups it belongs to"?

I've a simple class with 3 methods. I'm running the test using the testng.xml file written below. When I run the test I get Test 1, Test 2 in results. I was expecting to see Test 3 as well because Test3 is set to "alwaysRun=true" which should make the test always run irrespective of methods or groups it belongs to". So why isn't the result showing Test 3?

Thanks in advance

package Package1;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;


public class TestNGTesting 
{


 @BeforeTest(alwaysRun=true)
 public void Test1() 
{
    System.out.println("Test 1");
}

@Test(groups= {"MyGroup1"})
public void Test2() 
{
    System.out.println("Test 2");
}




 @Test(alwaysRun=true)
 public void Test3() 
{
    System.out.println("Test 8");
}     

}

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite"> 
 <test name="Test1">
<groups>
<run>
<include name="MyGroup1"/>
</run>
</groups> 
    <classes>
     <class name="Package1.TestNGTesting"/>
  </classes>
 </test> <!-- Test -->    
</suite> <!-- Suite -->

Upvotes: 0

Views: 1308

Answers (1)

Bhavesh Soni
Bhavesh Soni

Reputation: 198

Kindly add a group in Test 3 as well.

@Test(alwaysRun = true,groups = { "MyGroup1" }) public void Test3() { System.out.println("Test 8"); }

enter image description here

Upvotes: 1

Related Questions