0

I'm not able to run by test case from testng.xml file after run of file I'm getting that Total tests run: 0, Failures: 0, Skips: 0 but if I will try to run the test class directly then test will run.
Also I tried to run it from pom.xml but getting same output.
I tried many things but nothing fixed this, need help!
My XML file is

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name= "Suite1" parallel="tests" thread-count="2">

<listeners>
<listener class-name ="com.Test.listeners.AnnotationTransformer" />
<listener class-name ="com.Test.listeners.ExtentReportListeners" />
</listeners>

 <test name="Chrome"> 
<parameter name="browser" value= "GC" />
<classes>
<class name= "com.Test.testCase.LoginTest" />
</classes> 
</test>
</suite>  

My Test case class is

public class LoginTest extends BaseTest {

    @Test(priority=1, dataProviderClass=DataUtil.class , dataProvider="excelData")
    public void checkSignIn(Hashtable<String, String> data)
    {
        softAssert= new SoftAssert();
        HomePage home= new HomePage(driver, wait);
        LoginPage login= new LoginPage(driver, wait);
        CreateAccountPage account= new CreateAccountPage(driver, wait);
        home.clickSignInButton();
        login.enterCreateEmail(RandomGenerator.getStringForEmail()+"@gmail.com");
        login.clickCreateButton();
        account.selectGender(data.get("gender"));
        account.enterFisrtName(data.get("firstName"));
        account.enterLastName(data.get("lastName"));
        account.clickRegisterButton();
        softAssert.assertAll();
    }
    
    @Test(priority=2, dataProviderClass=DataUtil.class , dataProvider="excelData")
    public void addToCartProduct(Hashtable<String, String> data)
    {       
        softAssert= new SoftAssert();
        MyAccountPage account= new MyAccountPage(driver, wait);
        PaymentPage payment= new PaymentPage(driver, wait);
        softAssert.assertEquals(account.VerifyMyAccountPage(), data.get("accountName"));
        account.clickOnWomenMenu();
        account.clickOnAddToCartProduct();
        softAssert.assertEquals(account.verifyProductAddedToCart(), data.get("cartMessage"));
        softAssert.assertEquals(payment.verifyProductPrice(), data.get("productPrice"));
        payment.clickOnPayByBankWireButton();
        softAssert.assertEquals(payment.verifyOrderIsCompeleted(), data.get("orderCompleteMessage"));
        softAssert.assertAll();
    }
    
}    

BaseTest Class is

public class BaseTest {

    public WebDriver driver;
    public WebDriverWait wait;
    public JavascriptExecutor js;
    public SoftAssert softAssert;
    
    @Parameters({"browser"})
    @BeforeClass
    public void launchApplication(String browser) throws IOException
    {
        driver= DriverFactory.getBrowser(browser);
        wait= new WebDriverWait(driver, 20);    
        driver.get(PropertyReader.getInstance().getProperty("pageUrl"));        
    }
    
    
    @AfterClass
    public void closeApplication()
    {
        driver.close();
    }
}

Plese let me know what wrong I'm doing

Edit: Verbose Output-

Usage: <main class> [options] The XML suite files to run
  Options:
    -configfailurepolicy
      Configuration failure policy (skip or continue)
    -d
      Output directory
    -dataproviderthreadcount
      Number of threads to use when running data providers
    -excludegroups
      Comma-separated list of group names to  exclude
    -groups
      Comma-separated list of group names to be run
    -junit
      JUnit mode
      Default: false
    -listener
      List of .class files or list of class names implementing ITestListener 
      or ISuiteListener
    -methods
      Comma separated of test methods
      Default: []
    -methodselectors
      List of .class files or list of class names implementing IMethodSelector
    -mixed
      Mixed mode - autodetect the type of current test and run it with 
      appropriate runner
      Default: false
    -objectfactory
      List of .class files or list of class names implementing 
      ITestRunnerFactory 
    -parallel
      Parallel mode (methods, tests or classes)
      Possible Values: [tests, methods, classes, instances, none, true, false]
    -port
      The port
    -reporter
      Extended configuration for custom report listener
    -suitename
      Default name of test suite, if not specified in suite definition file or 
      source code
    -suitethreadpoolsize
      Size of the thread pool to use to run suites
      Default: 1
    -testclass
      The list of test classes
    -testjar
      A jar file containing the tests
    -testname
      Default name of test, if not specified in suitedefinition file or source 
      code 
    -testnames
      The list of test names to run
    -testrunfactory, -testRunFactory
      The factory used to create tests
    -threadcount
      Number of threads to use when running tests in parallel
    -usedefaultlisteners
      Whether to use the default listeners
      Default: true
    -log, -verbose
      Level of verbosity
    -xmlpathinjar
      The full path to the xml file inside the jar file (only valid if 
      -testjar was specified)
      Default: testng.xml

[TestNG] No tests found. Nothing was run
6
  • Please add verbose="2" in your testng.xml so that you can get the console logs and paste that console log here so that your testng <suite/> node will be like <suite name= "Suite1" parallel="tests" thread-count="2" verbose="2" >.use of verbose – Mohamed Sulaimaan Sheriff Jul 28 '20 at 6:19
  • @MohamedSulaimaanSheriff I have added the output in question please have a look. – Upkar Singh Jul 28 '20 at 6:45
  • How do you run your tests? – Alexey R. Jul 28 '20 at 10:46
  • @AlexeyR. I'm running my testng.xml file, also I tried to run my testng file from maven by using maven-surefire-plugin – Upkar Singh Jul 28 '20 at 11:32
  • Show your pom.xml and project structure – Alexey R. Jul 28 '20 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.