簡體   English   中英

Grails項目無法解析org.junit

[英]Grails project unable to resolve org.junit

我已經檢查了基於Maven的項目,由於某種原因,我無法克服測試類的編譯問題。 即使我通過grails命令創建了一個新測試,也無法對其進行編譯。

我收到的Error:Groovyc: unable to resolve class org.junit.AssertError:Groovyc: unable to resolve class org.junit.Assert的代碼

import exchange.TimetableController
import grails.converters.JSON
import grails.test.mixin.Mock
import grails.test.mixin.TestFor
import org.springframework.http.HttpStatus
import spock.lang.Specification

/**
 * See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions
 */
@TestFor(TimetableController)
@Mock([Person,Parallel,Course,Event,RestService])
class TimetableControllerSpec extends Specification {
(...)

..當我同時刪除@TestFor和@Mock批注時,文件將被編譯。 我應該從哪里開始?

查看您的pom文件。 確保它具有junit依賴項:

 <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
  </dependency>

如果要在IDE中進行構建,則可能還需要在此之后執行grails刷新依賴項。 命令行應該可以。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM