我试图使用selenium / java为自动化脚本运行maven项目。但是,当我执行mvn test命令时,测试无法运行。请让我知道当我尝试运行Maven Project时,黄瓜测试未执行的问题可能是什么。
[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] ------------------------------------------------------------------------
下面是我的POM.XML文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>KSAEpic3MavenProj</groupId>
<artifactId>KSAEpic3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>KSAEpic3</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope> </dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>ojdbc14</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</dependency>
</dependencies>
</project>
从IDE运行时记录-
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building KSAEpic3 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ KSAEpic3 ---
[debug] execute contextualize
[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:2.3.2:compile (default-compile) @ KSAEpic3 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ KSAEpic3 ---
[debug] execute contextualize
[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:2.3.2:testCompile (default-testCompile) @ KSAEpic3 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ KSAEpic3 ---
[INFO] Surefire report directory: D:\Maven WorkSpace\KSAEpic3\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.751s
[INFO] Finished at: Thu Jul 26 09:41:48 GST 2018
[INFO] Final Memory: 8M/19M
[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.
StepDefinition文件-
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();
}
}
答案 0 :(得分:3)
如果未明确指定,则测试类的名称很重要。
默认情况下,Surefire插件将自动包含所有带有following wildcard patterns:的测试类
“ ** / Test * .java”-包括其所有子目录以及所有以“ Test”开头的Java文件名。
“ ** / * Test.java”-包括其所有子目录以及所有以“ Test”结尾的Java文件名。
“ ** / * Tests.java”-包括其所有子目录以及所有以“ Tests”结尾的Java文件名。
“ ** / * TestCase.java”-包括其所有子目录和所有以“ TestCase”结尾的Java文件名。
您的课程名为vkCreate...()
,因此默认情况下无法识别。将其重命名为Epic2TestRunner.java
或TestEpic2Runner.java
将是可能的解决方案。