Monday 9 September 2019

java - How to jUnit Assert a Grails Controller Update of a Database column?

I have a grails controller which takes a simple string and updates a column in the DB by id. I want to write a jUnit test for this operation to make sure the update went through correctly....



  @Test
void "testUpdateNameOnMonsterById"() {

controller.params.id = 8;
controller.params.name = 'Godzilla';


controller.updateMosterNameById();
// what are the different jUnit assertetions that need to happen at this point?


For example should I query the DB and do assertEquals or assertTrue?



Any sample code with jUnit asserts would be greatly appreciated.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...