同事们,我的测试类apptest.java
中有@Ignore注释
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]复制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]跳过不存在的资源目录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
-------------------------------------------------------
Running com.adapter.AdapterAppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.546 sec - in com.adapter.AdapterAppTest
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-surefire-plugin:2.19:test (default) @ adapter ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.452 s
[INFO] Finished at: 2015-12-03T16:09:13+03:00
[INFO] Final Memory: 25M/413M
[INFO] ------------------------------------------------------------------------
为什么@Ignore注释没有效果?
您只展示了一小部分代码,但从我所看到的情况来看,我怀疑您使用的是JUnit3(扩展自Testcase并通过'test'前缀标识testmethods)。
Ignore注释仅适用于JUnit4测试,即:
Testmethods使用@Test进行注释,并且该类不是从TestCase继承的
使用现在发布的代码,将测试的开始更改为:
public class AdapterAppTest {
@Test
@Ignore("this test is not ready yet")
public static void testCreateApplicationWithAllRequiredParameters() {
为什么注释无效?
问题内容: 我仍然不清楚Java中注释的用途。最初,我认为它们只是作为文档。但是,我不确定从Google App Engine数据存储中 查看此文档。 @PersistenceCapable(identityType = IdentityType.APPLICATION) 看起来更像是方法签名。 这种注释的目的是什么?它有什么作用? 问题答案: 它们是源级元数据。它们是将信息添加到不是代码的信息中
我有一个简单的类叫BeaconDao 然而,当我用@service或@component标记beaconDao时,一切都运行得非常好。有人能看出问题所在吗?
问题内容: 我正在尝试使用Java批注,但似乎无法使我的代码认识到其中存在。我究竟做错了什么? 问题答案: 您需要使用注释界面上的@Retention注释将注释指定为运行时注释。 即
问题内容: 我知道有一些关于此的帖子,但是它们大约一年了,没有任何回应。实际上,我们在PostgreSQL 8.4上使用的是Hibernate 4.2.1.Final。我们有两个这样的实体 实体A(顶级层次结构类) 实体B(子类) 如您所见,使用注释了一个实体,但是当使用来获取顶级类时 我们也通过属性获得了B子类。实际上,SQL语句包含。这仍然是Hibernate第四版中的错误,还是我做错了什么?
问题内容: 我从Spring Framework开始,想做一个带有注释的HelloWorld,我已经创建了一个控制器和一个视图,我猜它是基本的hello工作。但是,我想使用注释,因为我不能再使用SimpleFormController(已弃用)。 我收到的错误是Estado HTTP 404-/av/index.jsp 我正在使用Netbeans,并将示例基于它提供的基本模板。我有以下文件,我可以