简体   繁体   English

TestNg xml没有显示错误-但在运行时会运行总计测试:0

[英]TestNg xml showing no error- but while running it gives Total tests run: 0

I have created a class file to print a message. 我创建了一个类文件来打印消息。 I also configured TestNG xml to execute the class. 我还配置了TestNG xml以执行该类。 Below is the contents of the XML file: 以下是XML文件的内容:

<?xml version="1.0" encoding="UTF-8"?>

<suite name="Sample test Suite">
   <test name="Sample test">
    <classes>
      <class name="signIn.MainMenu" />
    </classes>
  </test>
</suite>

Here is my source code of MainMenu.java: 这是我的MainMenu.java源代码:

package signIn; 
public class MainMenu { 
    public static void main(String args[]){ 
        System.out.println("message"); 
    } 
}

Can someone help please? 有人可以帮忙吗?

You need to define a Test via annotations first, 您需要先通过注释定义一个测试,

so try this source instead: 因此,请尝试使用以下来源:

import org.testng.annotations.Test;

public class MainMenu { 

    @Test
    public void test(){ 
       System.out.println("message"); 
    } 
}

and most important advice of all: 最重要的建议:

READ a tutorial on how to test with testNG!! 阅读有关如何使用testNG进行测试的教程!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试从 testng.xml 运行我的测试时出现 NullPointerException - NullPointerException while trying to run my tests from testng.xml 通过Maven运行testng.xml给出错误 - Running testng.xml via maven gives error Allure 报告显示未作为“Broken”运行的 testng 测试 - Allure reports showing the testng tests that are not run as 'Broken' 在套件中运行测试用例时在 XML testng 文件中出错 - Getting Error in XML testng file while running the test case in a suite 依次在TestNG Suite xml文件中运行测试 - Running tests in TestNG suite xml file sequentially TestNG:使用 Testng XML 文件运行特定的组测试 - TestNG: Running specific group tests using Testng XML file 通过Testng运行测试时出现内存问题 - Memory issue while running tests through testng 运行TestNG测试时出错 - Error While running TestNG test 通过testng Framework执行时,我的硒测试不是从cmd或Jenkins运行的。 结果:总测试次数:0,失败次数:0,跳过次数:0 - My selenium tests aren't running from either cmd or Jenkins when executed via testng Framework. Results: Total tests run: 0, Failures: 0, Skips: 0 TestNG XML 文件未按顺序运行测试 - Selenium ZD52387880E1EA22817A72D37592138 - TestNG XML file not running tests sequentially - Selenium Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM