Loading [MathJax]/jax/input/TeX/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >在mvn集成测试期间不运行selenium测试

在mvn集成测试期间不运行selenium测试
EN

Stack Overflow用户
提问于 2015-01-11 16:26:20
回答 2查看 729关注 0票数 1

我正在尝试使用Selenium测试我的web应用程序,将测试类与maven集成。当我给出命令mvn integration-test时,测试类被识别,但是测试没有被执行。最后,构建是成功的。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
     Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.228 sec

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.915s
[INFO] Finished at: Sun Jan 11 20:15:59 IST 2015
[INFO] Final Memory: 43M/303M
[INFO] ------------------------------------------

这是我的pom.xml文件

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<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>Music</groupId>
    <artifactId>Music</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <properties>
        <spring.version>3.0.5.RELEASE</spring.version>
        <spring.security.version>3.2.3.RELEASE</spring.security.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.24</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-app</artifactId>
            <version>1.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-parsers</artifactId>
            <version>1.5</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20140107</version>
        </dependency>
        <dependency>
            <groupId>org.jasypt</groupId>
            <artifactId>jasypt</artifactId>
            <version>1.9.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>
        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <version>2.4.9</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.3.Final</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency>
        <dependency>
            <groupId>org.jmock</groupId>
            <artifactId>jmock-junit4</artifactId>
            <version>2.6.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>2.25.0</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>5.10</version>
            <classifier>jdk15</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium.client-drivers</groupId>
            <artifactId>selenium-java-client-driver</artifactId>
            <version>1.0.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                    <systemProperties>
                        <property>
                            <name>user</name>
                            <value>tobrien</value>
                        </property>
                        <property>
                            <name>name</name>
                            <value>Tim O'Brien</value>
                        </property>
                    </systemProperties>
                </configuration>
                <executions>
                    <execution>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>selenium-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start-server</goal>
                        </goals>
                        <configuration>
                            <background>true</background>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

测试代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
public class FunctionalTest {
private Selenium selenium;

      @BeforeClass
      public void startSelenium() {
        this.selenium = new DefaultSelenium("localhost", 8080, "*chrome",
            "http://www.twitter.com");
        this.selenium.start();
      }
@Test
      @Parameters( { "user", "name" })
      public void testTwitter(String user, String name) {
        try {
          selenium.open("http://www.twitter.com/" + user);
          selenium.waitForPageToLoad("3000");
          assert selenium.isTextPresent(name);

        } catch (SeleniumException e) {
          throw e;
        }
      }
@AfterClass(alwaysRun = true)
      public void stopSelenium() {
        this.selenium.stop();
      }
}
EN

回答 2

Stack Overflow用户

发布于 2015-01-11 16:46:25

您已经在maven surefire插件的配置中添加了跳过测试标记

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skip>true</skip>
            ...
         </plugin>

此配置将跳过maven在“预集成-测试阶段”下运行所有阶段的测试。尝试将此值设置为false或将其完全删除。

票数 0
EN

Stack Overflow用户

发布于 2015-01-11 18:40:52

默认情况下,maven-surefire-plugin只在测试阶段运行。您需要通过添加在集成测试阶段运行的额外执行来启用它。是最佳实践,其中普通测试命名为*Test.java,集成测试命名为*IT.java:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<!-- Integration tests -->
<!-- Exclude *IT.java at test phase -->
<!-- Include *IT.java at integration-test phase, but exclude normal tests -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.7.1</version>
  <configuration>
    <excludes>
      <exclude>**/*IT.java</exclude>
    </excludes>
  </configuration>
  <executions>
    <execution>
      <id>integration-test</id>
      <goals>
        <goal>test</goal>
      </goals>
      <phase>integration-test</phase>
      <configuration>
        <excludes>
          <exclude>**/*Test.java</exclude>
        </excludes>
        <includes>
          <include>**/*IT.java</include>
        </includes>
      </configuration>
    </execution>
  </executions>
</plugin>

在maven-surefire-plugin中添加一个配置以排除测试,该配置以"*IT.java“结尾,以避免在测试阶段执行集成测试。然后为集成测试添加一个在集成测试阶段运行的执行。要覆盖用于测试阶段执行的共享插件配置,请在集成测试执行中指定一个配置。此配置包括集成测试("*IT.java"),不包括普通测试("*Test.java"),因为在集成测试阶段只应运行集成测试。普通测试仍将在测试阶段运行一次,但不会在集成测试阶段再次运行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27889344

复制
相关文章
【测试】Selenium Grid测试
下载http://selenium-release.storage.googleapis.com/index.html
瑞新
2020/07/07
1.1K0
【测试】Selenium Grid测试
基于unittest集成你的selenium2测试
前言 python单元测试框架(The Python Unit Testing Framework)简称PyUnit,是JUnit的python版本,自python2.1版本后,PyUnit已经成为了Python的标准库。下面我们就如何把unitest应用到python selenium2自动化测试中进行分享。 测试用例 单元测试是由一系列的测试用例(Test Cases)构成。测试用例是被设置用来检测独立场景的集合。在PyUnit中,unittest模块中的TestCase类代表测试用例。 TestCas
苦叶子
2018/04/04
7280
基于unittest集成你的selenium2测试
集成测试、单元测试、系统测试
为了使软件正常工作,所有单元都应集成在一起并正常运行。集成测试就像是要求不同工种的工人修建一个房子,希望他们都团结协作。如何判断他们在一起是否可以按照计划完成建设呢?唯一了解的方法是通过将它们全部拉在一起并测试它们如何相互作用来执行“集成测试”。软件开发和设计也是如此。
FunTester
2020/02/17
1.6K0
分层测试(四):集成测试
https://www.cnblogs.com/yuxiuyan/tag/分层测试/
于果
2023/02/27
3860
分层测试(四):集成测试
【测试】Selenium Webdriver API
更多操作: http://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.remote.webelement
瑞新
2020/07/07
2.5K0
集成测试是什么?为什么要做集成测试
集成测试,也叫组装测试或联合测试。在单元测试的基础上,将所有模块按照设计要求(如根据结构图)组装成为子系统或系统,进行集成测试。
测试小兵
2019/11/20
3.3K0
Selenium并行测试基础
随着技术的进步,组织从人工测试转向Selenium测试自动化,测试解决方案变得比以往更具可扩展性。但是,摆在大多数团队面前的还有一座山:并行测试的可伸缩性。许多公司仍在使用顺序测试方法来提供质量保证,这会消耗大量的时间,资源和精力。
FunTester
2020/05/18
5740
单元测试和集成测试
单元测试对构件的五方面进行测试:  (1)模块或构件接口;  (2)局部数据结构;  (3)边界条件;  (4)独立路径;和  (5)处理错误的路径
葆宁
2019/04/18
2.3K0
单元测试和集成测试
集成测试概述
http://mpvideo.qpic.cn/0b782iaaaaaaoaacyovm5fpfbuwdadjaaaaa.f10002.mp4?dis_k=15d3045601ae15530c8c951
归根落叶
2020/05/15
2.1K0
集成测试概述
【软件测试】自动化测试selenium(二)
我们可以看到,submit和click的效果是一样的,但是submit存在一定的弊端: 如果点击的元素放在form标签中,此时使用submit实现的效果和click是一样的.如果点击的元素放在非form标签中,此时使用submit会报错! 如下:(此时submit操作的不是from标签下的元素)
xxxflower
2023/10/16
3450
【软件测试】自动化测试selenium(二)
【软件测试】自动化测试selenium(一)
自动化测试是指使用软件工具或脚本来执行测试任务的过程,以替代人工进行重复性、繁琐或耗时的测试活动。通过编写脚本和使用自动化测试工具,可以自动执行测试用例、验证软件系统的功能和性能,并生成相应的测试结果和报告。
xxxflower
2023/10/16
1.5K0
【软件测试】自动化测试selenium(一)
测试思想-集成测试 关于接口测试 Part 2
5. 用例设计思想(举例说明) 如上表,是某个接口说明文档中的一个接口,课程检索,其中“v1/Lesson/testsrch/?” 为接口调用地址,此外,还给出了接口函数输出(即Server Re
授客
2019/09/10
6530
测试思想-集成测试 关于接口测试 Part 2
selenium自动化测试报告_selenium自动化测试断言
注意:driver.close() ,当前关闭的是主窗口,只有完成页面切换才可以关闭当前新的页面
全栈程序员站长
2022/11/15
2.5K0
selenium自动化测试报告_selenium自动化测试断言
软件测试术语 - 系统集成测试
本公众号所有内容,均属微信公众号: 开源优测 所有,任何媒体、网站或个人未经授权不得转载、链接、转贴或以其他方式复制发布/发表。已经本公众号协议授权的媒体、网站,在使用时必须注明"稿件来源微信公众号:开源优测",违者本公众号将依法追究责任。
孟船长
2019/01/24
1.6K0
软件测试术语 - 系统集成测试
软件测试|微服务集成测试策略
集成测试将模块收集在一起,并将它们作为一个子系统进行测试,以验证它们是否按照预期的方式进行协作,以实现更大的行为块。它们通过子系统执行通信路径,以检查每个模块对于如何与对等体交互的任何错误假设。
霍格沃兹测试开发Muller老师
2023/01/06
9480
【自动化测试】Selenium
web应用程序测试工具(录制、编写、运行、测试并行处理) api 编辑 并行测试
瑞新
2020/07/07
9090
软件测试|selenium弹窗操作
<font size='3'>说明:本篇博客基于selenium 4.1.0</font>说明操作弹窗共分两步:创建弹窗对象alert = driver.switch_to.alert操作弹窗print(alert.text) # 获取弹窗文本alert.send_keys('helloworld') # 弹窗输入,需要弹窗有输入框才能输入alert.accept() # 弹窗确定,等同于点击弹窗的'确定'按钮alert.dismiss()
霍格沃兹测试开发Muller老师
2022/12/28
6550
软件测试|Selenium常见api
Selenium提供了八种定位方式:https://www.selenium.dev/documentation/webdriver/elements/locators/
霍格沃兹测试开发Muller老师
2023/01/31
6920
软件测试|selenium css定位
selenium中的css定位,实际是通过css选择器来定位到具体元素,css选择器来自于css语法
霍格沃兹测试开发Muller老师
2022/12/28
7360
点击加载更多

相似问题

运行mvn集成测试不运行robotframework测试用例。

14

mvn集成-测试不执行黄瓜集成测试

13

在"mvn测试“运行中禁用selenium测试

13

mvn集成-测试不会运行我的测试

10

mvn集成-测试与mvn故障安全:集成-测试

12
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文