我是maven的初学者,我创建了一个maven项目,当我通过单击Maven Test
执行项目时,它不执行任何在@Test
注释下编写的测试用例。
但是当我使用Testng执行时,相同的代码然后它的工作正常。 任何人都可以解决它。
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>Webdriver</groupId>
<artifactId>Webdriver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<inherited>true</inherited>
<configuration>
<suiteXMLFiles>
<suiteXMLFile>testng.xml</suiteXMLFile>
</suiteXMLFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:2)
按照惯例,测试类也必须以&#34; Test&#34;结束。如果他们不这样做,你应该添加
<ul class="img-list-single">
<li>
<a>
<img src=<%= @post.url %>/>
<span class="text-content"><span><%=@post.title%></span></span>
</a>
<%= @comment.username%>
<%if current_user%>
<%= form_for :comment, :url => post_comments_path(@post) do |f|%>
<%= f.text_field :text %>
<%= f.submit%>
<% end %>
<%if current_user.id==@post.user_id%>
<%= button_to 'Delete', @post, method: :delete, :onclick => " returconfirm('Are you sure you want to delete this post?')"%>
<%end%>
<%end%>
到你的surefire配置(或任何包括你和你的文件命名方案的工作)。