vendredi 6 mars 2015

Grails test-app updating function being tested and test print out problems

I am running grails 2.3.3 in a GGTS.


I am successfully running a single unit test for a service function within the Spring GGTS.


I am hoping to be able to use this unit test to develop the particular function - such an approach will really speed up my development going forward.


This means I need to make changes to the service function that is being tested and then retest over and over again (no doubt a sad reflection on my coding skills!). The problem is when I make a change to the logic or any log.debug output it does not come through in the test. In other words the test continues to run against the original service function and not the updated one.


In order for me to force it to use the updated function the only way I have found that will do this is to restart the GGTS!


Is there a command I can use in GGTS to force a test on the most recent version of the function I am testing?


Here are the commands I am using within the GTTS:



test-app unit: UtilsService



I do run a clean after a function update without any success:



test-app -clean



I am also struggling with getting additional output from within the test function - introducing 'println' or 'log.debug' commands results in a failure of the test.


It would be useful to know of a good link to documentation about the test syntax - I have looked at grails section 12 about testing in general.


Here is the test file:



package homevu1

import grails.test.mixin.TestFor
import spock.lang.Specification

/**
* See the API for {@link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions
*/
@TestFor(UtilsService)
class UtilsServiceSpec extends Specification {

// to test utilSumTimes for example use the command :
// test-app utilSumTimes

// test-app HotelStay

def setup() {
}

def cleanup() {
}

void "test something"() {

when:
def currSec = service.utilSumTimeSecs( 27, 1, false)
//println "currSec" , currSec

then:
//println "currSec" , currSec
assert currSec == "26"


}
}


If I uncomment either of the println lines these comments are not displayed and the test fails.


Welcome any suggestions.


-mike


Aucun commentaire:

Enregistrer un commentaire