gpt4 book ai didi

eclipse - 无法使用Grails 2.2.1在GGTS 3.2中运行单元测试

转载 作者:行者123 更新时间:2023-12-02 15:33:09 26 4
gpt4 key购买 nike

我有一个自动生成的单元测试文件,如下所示:

package com.yuanjianlvye.szws

import grails.test.mixin.*
import org.junit.*

/**
* See the API for {@link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions
*/
@TestFor(ScreenResolutionService)
class ScreenResolutionServiceTests {

void testSomething() {
fail "Implement me"
}
}

如果我在GGTS中使用grails命令运行单元测试,如下所示:“test-app com.yuanjianlvye.szws.ScreenResolutionService”,我可以获得预期的答案。
Loading Grails 2.2.1
| Environment set to test.....
| Compiling 1 source files..
| Compiling 1 source files.....
| Running 1 unit test... 1 of 1
| Failure: testSomething(com.yuanjianlvye.szws.ScreenResolutionServiceTests)
| junit.framework.AssertionFailedError: Implement me
at junit.framework.Assert.fail(Assert.java:50)
at com.yuanjianlvye.szws.ScreenResolutionServiceTests.testSomething(ScreenResolutionServiceTests.groovy:15)
| Completed 1 unit test, 1 failed in 207ms

但是,如果我通过右键单击文件来运行单元测试,然后在弹出菜单中选择“Run As-> JUnit Test”,则会收到以下错误消息:
Class not found com.yuanjianlvye.szws.ScreenResolutionServiceTests
java.lang.ClassNotFoundException: com.yuanjianlvye.szws.ScreenResolutionServiceTests
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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

有人对此有任何想法吗?

最佳答案

我定期经历过。有时可以阻止所有“grails run-app”命令在后台运行,并使用“Project / Clean ...”菜单选项清理应用程序。

关于eclipse - 无法使用Grails 2.2.1在GGTS 3.2中运行单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16411078/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com