同事们,我在测试类中有@ignore注释 AppTest.java.
import java.math.BigInteger;
import java.util.UUID;
import org.fluttercode.datafactory.impl.DataFactory;
import org.junit.Ignore;
import org.junit.Test;
import junit.framework.TestCase;
public class AdapterAppTest extends TestCase {
@Ignore("this test is not ready yet")
public static void testCreateApplicationWithAllRequiredParameters() {
AdapterApp.setWsURL(URL);
AdapterApp adapterApp = new AdapterApp();
System.out.println("Set UP Request Parameters");
DataFactory df = new DataFactory();
adapterApp.setRequestTimestamp("2015-12-01T12:12:12.123"));
adapterApp.setRequestUid(UUID.randomUUID().toString());
adapterApp.setProductType("0");
String applicationNum = adapterApp.createApplication();
assertEquals("2 symb", 2, applicationNum.length());
}
}
我的pom看起来:
<!-- Spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>io.codearte.jfairy</groupId>
<artifactId>jfairy</artifactId>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>org.fluttercode.datafactory</groupId>
<artifactId>datafactory</artifactId>
<version>0.8</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.19</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>AdapterAppTest.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<mainClass>com.adapter</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.adapter</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.adapter_entities</generatePackage>
<schemas>
<schema>
<url>src/main/resources/Import.wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
</plugins>
结果我收到:
[INFO]扫描项目... [INFO] [INFO] ---------------------------------- -------------------------------------- [INFO]建筑适配器0.0.1-SNAPSHOT [INFO ] ------------------------------------------------- ----------------------- [INFO] [INFO] --- maven-jaxb2-plugin:0.13.0:generate(默认)@ adapter - - [INFO]源资源的最新检查[INFO] [INFO] --- maven-resources-plugin:2.6:资源(default-resources)@ adapter --- [INFO]使用'UTF-8'编码以复制过滤的资源 . [INFO]复制3个资源[INFO]复制1个资源[INFO] [INFO] --- maven-compiler-plugin:3.3:compile(default-compile)@ adapter --- [INFO]检测到更改 - 重新编译模块! [INFO]将25个源文件编译为C:\ Users \ git \ adapter \ adapter \ target \ classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources(default-testResources)@ adapter --- [INFO]使用“UTF-8”编码复制过滤后的资源 . [INFO]跳过不存在的resourceDirectory C:\ Users \ git \ adapter \ adapter \ src \ test \ resources [INFO] [INFO] --- maven-compiler-plugin:3.3:testCompile(default-testCompile)@ adapter - - [INFO]无需编译 - 所有类都是最新的[INFO] [INFO] --- maven-surefire-plugin:2.19:test(default-test)@ adapter --- -------- -----------------------------------------------
T E S T S.
运行com.adapter.AdapterAppTest
测试运行:1,失败:0,错误:0,跳过:0,经过的时间:3.546秒 - 在com.adapter.AdapterAppTest
结果:
测试运行:1,失败:0,错误:0,跳过:0
[信息]
[INFO] --- maven-surefire-plugin:2.19:test(默认)@ adapter ---
[INFO]跳过surefire的执行,因为它已经为此配置运行
[INFO] ----------------------------------------------- -------------------------
[信息] Build 成功
[INFO] ----------------------------------------------- -------------------------
[INFO]总时间:12.452秒
[INFO]完成于:2015-12-03T16:09:13 03:00
[INFO]最终记忆:25M / 413M
[INFO] ----------------------------------------------- -------------------------
为什么@Ignore注释没有效果?
1 回答
你只展示了很少的代码,但是从我看到的,我怀疑,你正在使用JUnit3(从Testcase扩展并通过'test'前缀识别testmethods .
Ignore注释仅适用于JUnit 4 Test,即:
TestTthods用@Test注释,该类不从TestCase继承
使用现在发布的代码,将测试的开始更改为: