当前位置: 首页 > 知识库问答 >
问题:

只有在远程机器中,TestnG结果才不会生成,结果是总测试运行次数:0,失败次数:0,跳过次数:0

阎德宇
2023-03-14

我知道这是最常见的问题,有很多解决方案

我知道这会有点长,但想根据以前的经验提供详细信息。

首先要考虑两件重要的事情:(我的测试套件由超过1K个测试用例组成)

>

如果我在100个测试用例以下运行,即使在远程机器上也能完美地生成它,但如果超过100个,那么这将导致总测试运行:0,失败:0,跳过:0(因此数据块报告也不会生成,但所有测试用例都能完美地执行)

尝试过的可能性:

>

  • 检查了所有方法的@test注释

    返回给定Void的所有@Test方法的类型

    仅导入Testng JAR

    所有方法都只有公共访问权限(非私有)

    TestNg在eclipse中正确配置

    完全刷卡并重新安装(也多次重启:()

    在构建路径中正确配置了所有必需的JAR

    配置:

    • 硒-3.7.1

    注:以上所有配置在本地都是相同的

    我不看代码也能理解,我们无法分析出哪里出了问题,但我不确定这是否有帮助,因为它在本地机器上工作,但共享所需的代码

    示例测试案例:

    import java.awt.AWTException;
    import java.awt.Robot;
    import java.awt.event.KeyEvent;
    import java.lang.reflect.Method;
    import java.net.MalformedURLException;
    import java.rmi.UnexpectedException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.NoSuchElementException;
    import java.util.Random;
    import java.util.Set;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.InvalidElementStateException;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.Keys;
    import org.openqa.selenium.StaleElementReferenceException;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.interactions.Actions;
    
    import org.testng.annotations.Test;
    import org.testng.asserts.SoftAssert;
    
    import com.pps.atm.pom.ccl.*;
    import com.pps.atm.pom.core_framework_components.*;
    import com.pps.atm.pom.dataproviders.*;
    import com.pps.atm.pom.dataproviders.URL_Setup.settingUrls;
    import com.pps.atm.pom.pages.admin.*;
    import com.pps.atm.pom.pages.frontend.*;
    import com.relevantcodes.extentreports.LogStatus;
    
    public class MyDev_Area_Local extends Local_DriverManager {
    
        @Test
        public void CK_DSK_LG_PopularToday_Newest_CTA_ActivateRewards_EUSignIn_SignInWithFB_Popup_Verification(
                Method method) throws InterruptedException, AWTException {
    
            ExtentTestManager.getTest().setDescription(
                    "Menu Popular today -> Automation Specific Store Category-> Newest tab, activate rewards existing user sign in sign in with FB popup verification..");
            ExtentTestManager.getTest().log(LogStatus.INFO, "Test case : " + method.getName()
                    + " - Execution Started With Thread ID  : " + Thread.currentThread().getId());
            System.out.println("Test case : " + method.getName() + " - Execution Started With Thread ID  : "
                    + Thread.currentThread().getId());
    
            // Respective pages object creation
            objHomePage = new HomePage(objDriver);
            objMenuItems = new MenuItems(objDriver);
            objVIP = new Voucher_Intermediate_Page(objDriver);
            objComCTA = new Common_CTA_Buttons(objDriver);
            objSUPLinkPage = new SignIn_Joinfree_Popup(objDriver);
            objStoreCategoryPage = new StoreCategoryPage(objDriver)
    

    Testng Xml文件:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    
    <suite
        name="PPS- Test Automation Framework for Desktop website - Local Execution"
        parallel="tests" thread-count="1">
    
        <listeners>
            <listener class-name="com.pps.atm.pom.core_framework_components.TestListener" />
        </listeners>
        <test name="Execution on Firefox" parallel="methods" thread-count="1">
    
            <parameter name="browser" value="firefox" />
            <parameter name="platform" value="WINDOWS" />
            <classes>
                <class name="com.pps.atm.pom.devarea.MyDev_Area_Local" />
            </classes>
        </test>
    </suite> 
    

    结果:

       [testng] [Parent 4896, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
       [testng] Testcase : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUserexecution completed with Thread ID : 10
       [testng] Testcase : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser - execution successfully completed :) ..!
       [testng] [GFX1-]: Receive IPC close with reason=AbnormalShutdown
       [testng] [GFX1-]: Receive IPC close with reason=AbnormalShutdown
       [testng] 1520507985755   geckodriver INFO    geckodriver 0.19.1
       [testng] 1520507985799   geckodriver INFO    Listening on 127.0.0.1:19279
       [testng] 1520507986370   mozrunner::runner   INFO    Running command: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2\\rust_mozprofile.pxDUcwVEb9zl"
       [testng] 1520507989413   Marionette  INFO    Enabled via --marionette
       [testng] [Parent 3220, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
       [testng] 1520508003543   Marionette  INFO    Listening on port 57333
       [testng] 1520508004282   Marionette  WARN    TLS certificate errors will be ignored for this session
       [testng] Mar 08, 2018 11:20:05 AM org.openqa.selenium.remote.ProtocolHandshake createSession
       [testng] INFO: Detected dialect: W3C
       [testng] Test execution started on browser  : firefox With Thread ID : 10
       [testng] Testcase : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser_From_JFPopUP - execution started ..!
    
           [testng] Test case : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser_From_JFPopUP - Execution Started With Thread ID  : 10
           [testng] JavaScript error: https://dev6ck.iamsavings.co.uk//themes/ck-storepage-v2/js/plugins.min.1519992761.js, line 22: SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
           [testng] R Value as 1157784
           [testng] Count  tab 2
           [testng] SignIn bonus as : 0.0
           [testng] Referal bonus as : 0.0
           [testng] UserReferral_Bonus_Value as : 0.0
           [testng] Count  tab 2
           [testng] Testcase : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser_From_JFPopUP - execution Failed :( - please look into this ..!
           [testng] [Parent 3220, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
           [testng] [GFX1-]: Receive IPC close with reason=AbnormalShutdown
           [testng] [GFX1-]: Receive IPC close with reason=AbnormalShutdown
           [testng] [Child 1728, Chrome_ChildThread] WARNING: pipe error: 232: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 513
           [testng] We are on - onFinish method : Execution on Firefox and finishing the testsuite execution ..!
           [testng] ===============================================
           [testng] PPS- Test Automation Framework for Desktop website - Local Execution
           [testng] Total tests run: 0, Failures: 0, Skips: 0
           [testng] ===============================================
           [testng] The tests failed.
        BUILD SUCCESSFUL
        Total time: 286 minutes 2 seconds*
    

    测试用例样本:

    @Test
        public void CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser_From_JFPopUP(
                Method method) throws InterruptedException, AWTException {
    
            ExtentTestManager.getTest().setDescription(
                    "Navigating to Admins for Settings -> Parnter settings -> Setting Signup value as Zero & referal bonus value as Zero and verifying from the front end..");
            ExtentTestManager.getTest().log(LogStatus.INFO, "Test case : " + method.getName()
                    + " - Execution Started With Thread ID  : " + Thread.currentThread().getId());
            System.out.println("Test case : " + method.getName() + " - Execution Started With Thread ID  : "
                    + Thread.currentThread().getId());
    
            objSoftAssertion = new SoftAssert();
            objJF_PopUpPage = new JoinFreePage(objDriver);
            objHomePage = new HomePage(objDriver);
            objMyAccounts = new MyAccounts_Page(objDriver);
            objAdminCoreFunc = new Admin_Core_Functions(objDriver);
            objAdminLoginPage = new Admin_Login_Page(objDriver);
            objPartner_Settings = new Settings_Partner_Settings(objDriver);
            objSUPLinkPage = new SignIn_Joinfree_Popup(objDriver);
            objUsersPage = new Users_Users_Page(objDriver);
            objReferEarnPage = new Refer_Earn_Page(objDriver);
            objAdmin_Search_Page = new Admin_Search_Page(objDriver);
    
            objComCon = new Common_Controls(objDriver);
            objComCTA = new Common_CTA_Buttons(objDriver);
    
            ExtentTestManager.getTest().log(LogStatus.INFO, "Navigating to home page and Joining In ...");
            objHomePage.navigateURL(objDriver);
    
            objHomePage.signinPopup_Header_LinkClick(objDriver);
            objSUPLinkPage.linkSignUp_Click(objDriver);
    
            ExtentTestManager.getTest().log(LogStatus.INFO, "Navigating to get captcha page and returns captcha code...");
            String strCaptchaValue = objSUPLinkPage.joinFreePopUp_Captch_Generation(objDriver);
    
            ExtentTestManager.getTest().log(LogStatus.INFO,
                    "Return back to Join free page and entering all join free page field values ...");
            String strNewJoin_UserEmail_1 = objJF_PopUpPage.joinFreePage_FeildValues_Entering_forUserName(objDriver,
                    strCaptchaValue);
            String strNewJoin_Password_1 = testdata.get(1).get("strPassword").trim();
            String strNewJoin_UserName_1 = testdata.get(1).get("strFirstName").trim();
            objHomePage.userLoggedIn_Verification(objDriver);
    
            ExtentTestManager.getTest().log(LogStatus.INFO, "Navigating to ReferFriend & fetching referral link ...");
            objHomePage.dropdown_MYAccounts_Click(objDriver);
            objMyAccounts.topMenu_ReferFriend_Navigation(objDriver);
            String strNewJoin_Referal_Link = objReferEarnPage.fetch_Referal_Link(objDriver);
            String[] strSplitValue = strNewJoin_Referal_Link.split("/r=");
            String strNewJoin_Referal_Value = strSplitValue[1];
    
            System.out.println("R Value as " + strNewJoin_Referal_Value);
    
            objSUPLinkPage.logOut_Verification(objDriver);
    
            ExtentTestManager.getTest().log(LogStatus.INFO,
                    "Navigating to admin URls and navigating to admin home page...");
            String strFurtherStatus_0 = CCL_Class.General.tabToggle_NavigateNewURL_Tab_count_2(objDriver,
                    (URL_Setup.settingUrls.admin_Url_Base).trim());
            objAdminLoginPage.enter_Credentials_And_Homepage_Navigation(objDriver);
    
            // Setting User Referal Bonus values in user sub tab @ User main tab
            ExtentTestManager.getTest().log(LogStatus.INFO,
                    "Navigating to adminSettings -> user main tab -> User sub tab -> User referral bonus ..");
            objAdminLoginPage.mainmenu_Users_Click(objDriver);
            objUsersPage.subMenu_Users_Navigation(objDriver);
    
            // Admin Search page
            objAdmin_Search_Page.searchPage_select_SearchBy(objDriver, "User Email");
            objAdmin_Search_Page.searchPage_Input_Keyword_UserTab(objDriver, strNewJoin_UserEmail_1);
            objAdmin_Search_Page.button_Submit_Users_Tab_User(objDriver);
    
            objUsersPage.editButton_ResultTable(objDriver, strNewJoin_Referal_Value);
    
            ExtentTestManager.getTest().log(LogStatus.INFO,
                    "Setting user referal bonus values in user edit page & saving the values  ...");
            float intUserReferral_Bonus_Value = (float) objUsersPage
                    .editPartnerDetails_input_User_Referral_Bonus_Value(objDriver, 0);
            objUsersPage.button_Save_Click(objDriver);
    
            ExtentTestManager.getTest().log(LogStatus.INFO,
                    "Navigating to adminSettings -> Parnter settings -> Setting Signup bonus values..");
            objAdminLoginPage.mainmenu_Settings_Click(objDriver);
            objPartner_Settings.subMenu_Partner_Settings_Navigation(objDriver);
            objPartner_Settings.editPartnerDetails_Editbutton_Click(objDriver);
    
            ExtentTestManager.getTest().log(LogStatus.INFO,
                    "Setting Signup & referal bonus values in Parnter settings edit page & saving the values  ...");
            float intSignUp_Bonus_Value = (float) objPartner_Settings.editPartnerDetails_input_SignUp_Bonus_Value(objDriver,
                    0);
            float intReferal_Bonus_Value = (float) objPartner_Settings
                    .editPartnerDetails_input_Referal_Bonus_Value(objDriver, 0);
            objPartner_Settings.button_Save_Click(objDriver);
    
            // will be removed
            System.out.println("SignIn bonus as : " + intSignUp_Bonus_Value);
            System.out.println("Referal bonus as : " + intReferal_Bonus_Value);
            System.out.println("UserReferral_Bonus_Value as : " + intUserReferral_Bonus_Value);
    
            ExtentTestManager.getTest().log(LogStatus.INFO, "Opening new tab and navigating to join free page to join...");
            String strFurtherStatus = CCL_Class.General.tabToggle_NavigateNewURL_Tab_count_2(objDriver,
                    (URL_Setup.settingUrls.url_Home).trim());
            objHomePage.signinPopup_Header_LinkClick(objDriver);
            objSUPLinkPage.linkSignUp_Click(objDriver);
    
            if (strFurtherStatus.contains("Success")) {
    
                objJF_PopUpPage.joinFreePage_Navigated_Verification(objDriver);
    
                ExtentTestManager.getTest().log(LogStatus.INFO,
                        "Opened new tab & Navigating to navigate join free page ...");
                String strCaptchaValue_1 = objSUPLinkPage.joinFreePage_Captch_Generation_Tab_Count_3(objDriver);
    
                ExtentTestManager.getTest().log(LogStatus.INFO,
                        "Return back to Join free page and entering all join free page field values ...");
                objJF_PopUpPage.joinFreePage_FeildValues_Entering(objDriver, strCaptchaValue_1);
                objHomePage.userLoggedIn_Verification(objDriver);
    
                objHomePage.dropdown_MYAccounts_Click(objDriver);
                objMyAccounts.topMenu_MyEarnings_Navigation(objDriver);
                objMyAccounts.tab_MyEarnings_CBEarnings_Navigation(objDriver);
    
                float intAvailableCB = objMyAccounts.cash_MyEarningsTab_AvailableCB(objDriver);
    
                // Asserting the Cashback value with backend singup bonus data
                if (intAvailableCB == intSignUp_Bonus_Value) {
    
                    ExtentTestManager.getTest().log(LogStatus.INFO,
                            "Successfully, Asserted live cashback & backend singup bonus data");
    
                } else {
    
                    ExtentTestManager.getTest().log(LogStatus.FAIL,
                            "Assertion failed - for live cashback & backend singup bonus data");
                }
    
                System.out.println("SignIn bonus from frontend as : " + intAvailableCB);
    
            } else {
    
                ExtentTestManager.getTest().log(LogStatus.FAIL,
                        "not able to Open new tab and navigating to join free page to join...");
            }
    
            ExtentTestManager.getTest().log(LogStatus.INFO,
                    "Verified successfully that user as Joined with respective signup  values entered in backend ...");
            ExtentTestManager.getTest().log(LogStatus.INFO, "Testcase : " + method.getName()
                    + "execution completed with Thread ID : " + Thread.currentThread().getId());
            System.out.println("Testcase : " + method.getName() + "execution completed with Thread ID : "
                    + Thread.currentThread().getId());
        }
    
  • 共有1个答案

    经博延
    2023-03-14

    重命名测试类,并与“测试”作为后缀或前缀连接。通常,构建自动化工具,如ANT或MAVEN,通过这个后缀或前缀来识别测试类。你的类名应该是这样的:

    MyDev_Area_LocalTest
    
     类似资料:
    • Selenium和自动化的新概念。 首先,当我使用Junit运行这些测试时,我的测试在Eclipse中运行良好。但是如果我通过Jenkins或CLI启动测试,我会得到结果:总测试运行:0,失败:0,跳过:0 现在我可能把考试的结构弄错了,或者我可能做了一些完全错误的事情。我已经浏览了所有的网站,所有的在线解决方案似乎都无法解决我的问题。 我的测试只是一个简单的登录测试。 我想我可能把这些框架弄混了

    • 我试图通过命令行(Windows env)运行cucumber标签。我正确配置pom.xml和maven。我按下命令就像- D:\apache-maven-3.6.0\bin D:\apache-maven-3.6.0\bin D:\apache-maven-3.6.0\bin 输出如下所述 请建议。 附加了我的pom.xmlCMD输出Eclipse项目结构

    • 我有一个Kafka主题(1.0.0),只有一个分区。消费者被封装在EAR中,当部署到Wildfly 10时,最后一条消息的轮询始终返回0条消息。虽然主题不是空的。 当我做民意测验时,我得到0条记录。尽管日志记录显示: 当我更改为-2时,如: 我确实收到一条消息: 当然,这不是正确的记录,消息377408在哪里? 尝试了许多方法来寻求结束等,但它从来没有工作。 这是我的消费者配置: 注意:我尝试了r

    • 如何从0-5只生成两次随机数。例如,结果应该是类似于0,1,0,2,1,3,4,2,3,4的结果,但它应该是随机的。这些数字只能使用两次。当我再次运行它时,结果应该再次随机,但数字应该使用两次。

    • 问题内容: 我们需要编写一个Node.js函数,该函数轮询某个API端点以获取先前请求的计算结果。结果需要一个随机的时间才能生成,而可能根本不生成。我们希望尽快得到它,但是我也不想等待太久,这意味着在一定数量的API调用之后,我们希望函数失败(拒绝Promise)。 我们的代码和API之间存在一种通信方式。 这是正确的方法吗? 问题答案: 否。这是构造函数antipattern的async/awa

    • 安装程序:我有一个扩展IRetryAnalyzer的类,并实现了一个简单的重试逻辑,覆盖了以下方法:public boolean retry(ITestResult result){ 提前道谢。