I have my domain Class and my groovy class for unit test
class Product {
String product_code
String store
int price
String notes
//static hasOne = [description: Description]
static constraints = {
product_code blank:false, size: 1..15
price blank:false, scale: 2
store blank:false, size: 1..40
notes blank:true , size: 1..150
}
}
import org.apache.jasper.compiler.Node.ParamsAction;
import grails.test.mixin.*
import org.junit.*
import org.pricer.model.Product;
/**
* See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
*/
@TestFor(Product)
class ProductTests {
void testSomething() {
if (Product.hasErrors()){
fail "not pass"
}else
assert "Pass"
}
}
when i try tu run test-app my ProductTest.testSomething i get
No signature of method: org.pricer.model.Product.hasErrors() is applicable for argument types: () values: [] Possible solutions: hasErrors(), getErrors(), setErrors(org.springframework.validation.Errors), clearErrors(), hashCode() groovy.lang.MissingMethodException: No signature of method: org.pricer.model.Product.hasErrors() is applicable for argument types: () values: [] Possible solutions: hasErrors(), getErrors(), setErrors(org.springframework.validation.Errors), clearErrors(), hashCode() at org.grails.datastore.gorm.GormStaticApi.methodMissing(GormStaticApi.groovy:97) at org.pricer.ProductTests.testSomething(ProductTests.groovy:20)
Aucun commentaire:
Enregistrer un commentaire