Monday, September 9, 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

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...