Register at GrailsUnitTestCase?

How to configure registration in grails block module?

When I try log.infoor log.debug, the output files .txtare empty, even after I tried to add a console appender. What's going on here?

+3
source share
3 answers

It may help, it is taken from release notes 1.2

By default, grails does not show exit from your tests. You can do it by doing this by passing -echoOut and / or -echoErr to the test-app:

grails test-app -echoOut -echoErr

+2
source

GrailsUnitTestCase, mockLogging(), Grails unit test, . .

0

I could not use mockLogging in grails 1.3.7 with GrailsUnitTestCase. I think there is probably a bug and it can work in Grails 2.0. Here is what I did to get around this:

class Foo {
    String name

    Long invokeLogTest(String key) {
        if (key.empty) {
            log.error("key was sent as empty string")
            return 10
        }  
    }
}

void testErrorCase() {
    def f = new Foo(name:'jp')
    f.metaClass.log = [error:{}]
    assert 10 == f.invokeLogTest("")
}
0
source

Source: https://habr.com/ru/post/1748455/


All Articles