Пытаюсь разобраться с тестами контроллеров.
Сделал как в примере petclinic. Тесты отваливаются с
NullPointerException в GrailsDomainConfigurationUtil.class на строке
boolean hasHibernate =
PluginManagerHolder.getPluginManager().hasGrailsPlugin("hibernate");
Попытался запустить тесты из примера Perclinic (grails test-app). Два
теста завершаются с ошибкой NullPointerException.
-------------------------------------------------------
Running 6 unit tests...
Running test org.grails.samples.OwnerControllerTests...
testAddInvalidOwner...FAILED
testValidOwner...FAILED
Tests Completed in 6335ms ...
-------------------------------------------------------
Tests passed: 4
Tests failed: 2
-------------------------------------------------------
код теста:
void testRegistration()
{
def controller = newInstance();
mockDomain(Registration);
controller.params.Registration = [name: 'John Due', email:
'
jo...@dot.com'];
controller.registration();
}
код из контроллера:
def registration = {
def domain = new Registration();
if (params.Registration)
{
domain.properties = params.Registration;
if (domain.save()) // где-то в недрах save отваливается
{
return;
}
}
return [domain: domain];
}
p.s. grails 1.3.3