- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正尝试在现有的 netbeans 应用程序上添加一些功能测试。
应用信息:maven打包,使用netbeans platform 7.3.1。我添加了此 article 中描述的依赖项但有异常(exception):
Running qa.FuncTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.067 sec <<< FAILURE! - in qa.FuncTest
org.netbeans.junit.NbModuleSuite$S@67ad77a7(org.netbeans.junit.NbModuleSuite$S) Time elapsed: 0.066 sec <<< ERROR!
java.lang.ClassNotFoundException: org.netbeans.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.netbeans.junit.NbModuleSuite$S.runInRuntimeContainer(NbModuleSuite.java:819)
at org.netbeans.junit.NbModuleSuite$S.access$100(NbModuleSuite.java:667)
有人知道为什么会这样吗?以及如何解决?提前致谢。
UPD 来自 application/pom.xml 的依赖部分
<dependencies>
<dependency>
<groupId>org.netbeans.cluster</groupId>
<artifactId>platform</artifactId>
<version>${software.netbeans.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-jdesktop-beansbinding</artifactId>
<version>${software.netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-nbjunit</artifactId>
<version>${software.netbeans.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-jellytools-platform</artifactId>
<version>${software.netbeans.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
UPD1测试类:
package qa;
import junit.framework.Test;
import org.netbeans.jellytools.JellyTestCase;
import org.netbeans.jellytools.OptionsOperator;
import org.netbeans.junit.NbModuleSuite;
import org.openide.windows.TopComponent;
public class FuncTest extends JellyTestCase {
public static Test suite() {
return NbModuleSuite.allModules(FuncTest.class);
}
public FuncTest(String n) {
super(n);
}
public void testWhatever() throws Exception {
TopComponent tc = new TopComponent();
tc.setName("label");
tc.open();
OptionsOperator.invoke().selectMiscellaneous();
Thread.sleep(5000);
System.err.println("OK.");
}
}
最佳答案
我想分享我的调查结果。我注意到应用程序何时像往常一样启动,我在输出窗口中看到:
Installation =.../application/target/application/extra
.../application/target/application/java
.../application/target/application/kws
.../application/target/application/platform
但是当通过 nbjubit/jellytool 启动应用程序时,我只看到:
Installation =.../application/target/application/platform
所以我决定扩展这个值并研究源代码。让我们考虑 NbModuleSuite.java 中的一些有趣的方法:
private static String[] tokenizePath(String path) {
List<String> l = new ArrayList<String>();
StringTokenizer tok = new StringTokenizer(path, ":;", true); // NOI18N
.....
}
static File findPlatform() {
String clusterPath = System.getProperty("cluster.path.final"); // NOI18N
if (clusterPath != null) {
for (String piece : tokenizePath(clusterPath)) {
File d = new File(piece);
if (d.getName().matches("platform\\d*")) {
return d;
}
}
}
String allClusters = System.getProperty("all.clusters"); // #194794
if (allClusters != null) {
File d = new File(allClusters, "platform"); // do not bother with old numbered variants
if (d.isDirectory()) {
return d;
}
}
....
}
static void findClusters(Collection<File> clusters, List<String> regExps) throws IOException {
File plat = findPlatform().getCanonicalFile();
String selectiveClusters = System.getProperty("cluster.path.final"); // NOI18N
Set<File> path;
if (selectiveClusters != null) {
path = new TreeSet<File>();
for (String p : tokenizePath(selectiveClusters)) {
File f = new File(p);
path.add(f.getCanonicalFile());
}
} else {
File parent;
String allClusters = System.getProperty("all.clusters"); // #194794
if (allClusters != null) {
parent = new File(allClusters);
} else {
parent = plat.getParentFile();
}
path = new TreeSet<File>(Arrays.asList(parent.listFiles()));
}
....
}
如您所见,我们可以在 cluster.path.final
或 all.clusters
中设置路径值并使用 ;
:
作为分隔符。我花了一些时间来研究这个常量,并意识到设置没有在 pom.xml 中设置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${software.maven-surefire-plugin}</version>
<configuration>
<skipTests>false</skipTests>
<systemPropertyVariables>
<branding.token>${brandingToken}</branding.token>
<!--problem part start-->
<property>
<name>cluster.path.final</name>
<value>${project.build.directory}/${brandingToken}/platform:${project.build.directory}/${brandingToken}/java:...etc</value>
</property>
<!--problem part end-->
</systemPropertyVariables>
</configuration>
</plugin>
但这很好用:
<properties>
<cluster.path.final>${project.build.directory}/${brandingToken}/platform:${project.build.directory}/${brandingToken}/java:...etc</cluster.path.final>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${software.maven-surefire-plugin}</version>
<configuration>
<skipTests>false</skipTests>
<systemPropertyVariables>
<branding.token>${brandingToken}</branding.token>
<cluster.path.final>${cluster.path.final}</cluster.path.final>
</systemPropertyVariables>
</configuration>
</plugin>
我不知道为什么会这样,但我建议使用 Maven 部分 properties
来设置 maven-surefire-plugin 的 systemPropertyVariables。祝你好运!
关于java - 功能测试 (Jellytools) 不在 netbeans 平台上启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38344408/
我目前正在用 Python 编写 Java 反编译器,并希望添加一些自动化功能测试。我有一堆简短的 Java 代码,需要确保它们反编译没有错误,输出代码编译,并且生成的程序给出预期的输出。 我计划使用
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
如何对 .net mvc Controller /操作进行功能测试。 我刚刚经历了多年的 Rails 开发,开始从事 .net mvc 的工作。这很痛苦,但我希望这很大程度上只是学习曲线。 对我而言,
我设置了 grunt 任务,以便在我的本地机器上使用 CasperJS 进行一些功能测试。一切正常。 我想知道是否有办法一直运行测试直到失败?或者通过一定次数的测试? 最佳答案 在 powershel
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 5个月前关闭。 Improve this q
我在 Wiki 和其他几个地方阅读有关功能测试的内容,但我没有明白一件事 - 为什么它被视为纯粹的黑盒测试?当我测试功能时,我经常依赖于实现方面的知识,或者至少依赖于诸如边界值(或数据库中的数据类型等
我想为 java servlet 编写一些功能测试,并且我想确保它适用于所有可能干扰 servlet 的过滤器和其他随机 java web 内容。在 Java 中有没有好的方法来做到这一点? 我注意到
我希望有人能阐明我面临的这个问题。 [问题] 我在功能单元测试中模拟了 doctrine.orm.default_entity_manager 服务。我将其注入(inject)到客户端服务容器中,这样
我们有一个 Mule 应用程序,它有 6 个或 7 个流,每个流大约有 5 个组件。 这是设置。 我们将 JMS 请求发送到 ActiveMQ 队列。骡听着。根据消息的内容,我们将其转发到相应的流。
我发现 Symfony2 中的功能测试总是尝试将页面请求为“http://localhost” 我的环境是用虚拟主机设置的,所以我的应用程序位于“http://symfony.dev” 经过一些测试,
我有一个 Controller ,我想为其创建功能测试。该 Controller 通过 MyApiClient 向外部 API 发出 HTTP 请求。类(class)。我需要模拟这个 MyApiCli
如题。 ruby test / functionals / whatevertest.rb不起作用,这需要我将所有require 'test_helper'替换为require File.dirnam
我正在使用Grails的功能测试插件为我的RESTful API项目准备功能测试用例。 我无法使用适用于我的其他情况的技术上传文件。 class CreateFunctionalSpec{ final
我有一个用 Python 3 编写的 API 包装类 WfcAPI,我想使用 PyUnit 对其进行测试. WfcAPI 的 setUpClass() 涉及登录到外部 API 服务器。当前功能测试实现
如果操作返回 json 对象,我如何在 Symfony 功能测试中测试响应? 我有密码 with('response')->begin()-> isHeader('content-type','a
我刚开始使用 AngularJS 进行测试。请帮我解决它。我的剧本 angular.module('test', []) .controller('ctrl', ['$scope', 'svc', f
你好, 我一直在思考描述特征的实质(Gherkin语法),找不到最佳答案。 同一场景的两个例子: Scenario: Creation of a new task Given I see the bu
我正在 Julia 中处理一组函数,我必须开发一组覆盖测试。我有一个函数在一个元组中返回 3 个值。 我怎样才能做这样的测试: @test_approx_eq_eps() 这将适用于所有三个输出值,它
我应该为所有嵌套方法编写单元测试,还是为调用者编写一个测试就足够了? 例如: void Main() { var x = new A().AFoo(); } public class A {
最近在研究django测试。因为我需要在我的网站上构建单元测试和集成测试。但是我发现 django 中集成测试的教程真的很少,而且经常在我点击名为“集成测试”的链接时出现,我只看到标题“功能测试”。那
我是一名优秀的程序员,十分优秀!