Currently searching for tutorials, explanations and examples. I've tried different examples and came up to different errors. My current error is :
| Error Compilation error compiling [unit] tests: startup failed:
and in my test reports. It outputs this :
Unit Test Results - Summary No tests executed.
My "UserSpec.groovy" code is this :
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"
}
}
Can anybody help. I'm new in grails. Thanks!
Additional to the above problem, when I omitted the Contraints in class as shown :
class UserSpec extends Specification {
I came up to this error :
| Running 1 unit test... 1 of 1 | Failure: initializationError(org.junit.runner.manipulation.Filter) | java.lang.Exception: No tests found matching grails test target pattern filter from org.junit.runner.Request$1@12c27788 at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35) at org.junit.runner.JUnitCore.run(JUnitCore.java:138) | Completed 1 unit test, 1 failed in 0m 0s | Error Fatal error running tests: Not-null property references a transient value - transient instance must be saved before current operation : newmyproject245.Order.product -> newmyproject245.Product; nested exception is org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : newmyproject245.Order.product -> newmyproject245.Product (Use --stacktrace to see the full trace)
someone help. Again, Thanks!