尝试运行Maven项目时,未执行Selenium WebDriver/Cucumber测试

尝试运行Maven项目时,未执行Selenium WebDriver/Cucumber测试,maven,selenium-webdriver,cucumber,maven-3,Maven,Selenium Webdriver,Cucumber,Maven 3,我试图使用selenium/java为我的自动化脚本运行maven项目。然而,当我执行MVNTest命令时,测试并没有运行。请让我知道,当我尝试运行maven项目时,cucumber测试没有得到执行可能是什么问题 [INFO] Scanning for projects... [INFO] [INFO] ---------------------< KSAEpic3MavenProj:KSAEpic3 >--------------------- [INFO] Building KS

我试图使用selenium/java为我的自动化脚本运行maven项目。然而,当我执行MVNTest命令时,测试并没有运行。请让我知道,当我尝试运行maven项目时,cucumber测试没有得到执行可能是什么问题

[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< KSAEpic3MavenProj:KSAEpic3 >---------------------
[INFO] Building KSAEpic3 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ KSAEpic3 -
--
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ KSAEpic3 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ KS
AEpic3 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ KSAEpic
3 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ KSAEpic3 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.628 s
[INFO] Finished at: 2018-07-26T08:57:14+04:00
[INFO] ------------------------------------------------------------------------
跑步班

package testrunner;

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(

        plugin={"pretty", "html:target/cucumber", "json:target/JSON/Output.json"},      
                features={"D:/KSA-Online Banking-AutomationFramework/Epic2Maven/src/test/resources/features"},

//      plugin={"com.cucumber.listener.ExtentCucumberFormatter:"},
tags={"@SI_TransferBtwAccounts"},

        glue={"stepdefinition"}

        )

public class Epic2TestRunner {

}
功能文件-

@SI_TransferBtwAccounts
Feature: Verify that SI is setup successfully Between the accounts and record is inserted in DB
Scenario: Verify that SI is setup successfully between the accounts
Given When browser is launched and KSA URL is loaded
    When STAFFUser1 logins to application
    When Password is entered
    When clicked on Login button
    When clicks on Pay&Transfer Icon
    When clicks on Transfer link
    When clicks on StandingInstruction link
     When selects TransferBtwAccount option
      When enters Trnsfrbtwaccamount in the field
    When FromandToDate are captured
       When Terms&Conditions are checked
    When clicked on continue button
       When StartandEnd Dates are verified in pre-confirmation screen
    When Entered OTP
    When clicked on Confirm button
    When Captured the Reference number
    When Record is displayed in StandingInstruction DB
    When record is displayed in the Standing Instruction menu
    Then user should be logged out of application.
步骤定义文件-

public class Transfer_SI_BtwAccounts  extends Browser_Initialization {

    private static String FromDate , ToDate, SIRefnum, refnumber, PurposeofTransferText, amount;

    @When("^STAFFUser(\\d+) logins to application$")
    public void staffuser_logins_to_application(int arg1) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
try {

            c_InputText("KSAOnlineBanking_Login_Username", GetPropertValue("StaffUssername"));

        } catch (Exception e ) {
            Assert.fail("unable to enter username"); 

        }
    }

    @When("^selects TransferBtwAccount option$")
    public void selects_TransferBtwAccount_option() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
       try {

           Thread.sleep(10000);

            c_click("TransferList");

            c_click("SI-BTWACC");

       } catch (Exception e ) {
           Assert.fail("unable to select option");
       }
    }

    @When("^enters Trnsfrbtwaccamount in the field$")
    public void enters_Trnsfrbtwaccamount_in_the_field() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
      try {
          Thread.sleep(6000);

          c_InputText("TBTWACCAmountField",GetPropertValue("EnterAmount"));

      } catch (Exception e ) {
          e.printStackTrace();
      }
    }

如果没有明确指定,测试类的名称很重要

默认情况下,Surefire插件将自动包含具有

“**/Test*.java”-包括其所有子目录和以“Test”开头的所有java文件名。
“***Test.java”-包括其所有子目录和以“Test”结尾的所有java文件名。
“***Tests.java”-包括其所有子目录和以“Tests”结尾的所有java文件名。
“***TestCase.java”-包括其所有子目录和以“TestCase”结尾的所有java文件名


您的类名为
Epic2TestRunner.java
,因此默认情况下无法识别。将其重命名为
TestEpic2Runner.java
epic2runertest.java
将是一个可能的解决方案。

您能够通过IDE运行它们吗?不,也不能从IDE运行。请查看IDE中编辑的日志。您可以共享runner类吗?我已经共享了runner类。请看上面。thnx您不应该为特性使用绝对路径,而是可以使用
features={“src/test/resources/features”}
。无论如何,这与当前问题无关。您能否共享步骤定义和功能文件中的一个,在此之前,请确保步骤定义中的
@SI_TransferBtwAccounts
与功能文件中的完全相同。感谢@SubOptimal将名称更改为TestEpic2Runner.java解决了我的问题。再次感谢
@SI_TransferBtwAccounts
Feature: Verify that SI is setup successfully Between the accounts and record is inserted in DB
Scenario: Verify that SI is setup successfully between the accounts
Given When browser is launched and KSA URL is loaded
    When STAFFUser1 logins to application
    When Password is entered
    When clicked on Login button
    When clicks on Pay&Transfer Icon
    When clicks on Transfer link
    When clicks on StandingInstruction link
     When selects TransferBtwAccount option
      When enters Trnsfrbtwaccamount in the field
    When FromandToDate are captured
       When Terms&Conditions are checked
    When clicked on continue button
       When StartandEnd Dates are verified in pre-confirmation screen
    When Entered OTP
    When clicked on Confirm button
    When Captured the Reference number
    When Record is displayed in StandingInstruction DB
    When record is displayed in the Standing Instruction menu
    Then user should be logged out of application.
public class Transfer_SI_BtwAccounts  extends Browser_Initialization {

    private static String FromDate , ToDate, SIRefnum, refnumber, PurposeofTransferText, amount;

    @When("^STAFFUser(\\d+) logins to application$")
    public void staffuser_logins_to_application(int arg1) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
try {

            c_InputText("KSAOnlineBanking_Login_Username", GetPropertValue("StaffUssername"));

        } catch (Exception e ) {
            Assert.fail("unable to enter username"); 

        }
    }

    @When("^selects TransferBtwAccount option$")
    public void selects_TransferBtwAccount_option() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
       try {

           Thread.sleep(10000);

            c_click("TransferList");

            c_click("SI-BTWACC");

       } catch (Exception e ) {
           Assert.fail("unable to select option");
       }
    }

    @When("^enters Trnsfrbtwaccamount in the field$")
    public void enters_Trnsfrbtwaccamount_in_the_field() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
      try {
          Thread.sleep(6000);

          c_InputText("TBTWACCAmountField",GetPropertValue("EnterAmount"));

      } catch (Exception e ) {
          e.printStackTrace();
      }
    }