현재 자습서, 설명 및 예제를 검색합니다. 다른 예제를 시도하고 다른 오류가 발생했습니다. 현재 오류 :Grails를 사용하여 도메인 클래스에 대한 단위 테스트
| [단위] 테스트를 컴파일하는 중 오류 컴파일 오류가 발생했습니다. 시작 실패 :
및 테스트 보고서에 있습니다.
단위 테스트 결과 - 요약 테스트가 실행되지 않았습니다.
package newmyproject245
import grails.test.mixin.*
import spock.lang.Specification
@TestFor(User)
class UserSpec extends ConstraintSpecification {
def setup() {
Expectations.applyTo User
}
def cleanup() {
}
void testShouldDoNothing() {
Expectations.applyTo User
user."password is not blank"
user."password is not nullable"
user."name is not blank"
user."name is not nullable"
}
void testEventNameConstraints() {
Expectations.applyTo User
def user = new User()
user."name is not blank"
user."name is not nullable"
}
}
수 누구의 도움 :
내 "UserSpec.groovy"코드이있다. 나는 grails에서 새로운 사람이다. 감사합니다. 내가 클래스의 제약 조건를 생략하면 위의 문제에 대한 추가
이 이와 같이
class UserSpec extends Specification {
내가이 오류에 와서 :
| 1 단위 테스트 실행 중 ... 1 of 1 | 실패 : initializationError (org.junit.runner.manipulation.Filter) | java.lang.Exception : grails와 일치하는 테스트가 없습니다. test target [email protected]의 패턴 필터 at org.junit.internal.requests.FilterRequest.getRunner (FilterRequest.java:35) at org .junit.runner.JUnitCore.run (JUnitCore.java:138) | 1 단위 테스트 완료, 0 실패 0 0 | 오류 테스트 실행 중 오류 발생 : 일시적인 값을 참조하는 null이 아닌 속성 - 일시적인 인스턴스가 현재 작업 전에 저장되어야 함 : newmyproject245.Order.product -> newmyproject245.Product; 중첩 예외는 org.hibernate.TransientPropertyValueException : 일시적인 값을 참조하는 null이 아닌 속성 - 현재 작업 이전에 임시 인스턴스를 저장해야 함 : newmyproject245.Order.product -> newmyproject245.Product (전체 추적을 보려면 --stacktrace를 사용하십시오)
누군가 도움이됩니다. 다시 고마워!