grails - Integration test all possibilities within one test case -


i running test see if email valid - valid in not in use within application user.

i want show when valid email entered, assert true hold, , when invalid email entered, assert false holds.

my code follows:

class usercontrollerintegrationtests extends groovytestcase{  @before void setup() {     // setup logic here }  @after void teardown() {     // tear down logic here }  @test void testvalidateemail() {      def usercontroller = new usercontroller()      usercontroller.params.email = "ddewdd@a.com"     usercontroller.validateemail()      assertequals "true", usercontroller.response.contentasstring      usercontroller.params.email = "a@a.com"     usercontroller.validateemail()      assertequals "false", usercontroller.response.contentasstring   } 

}

my validateemail() in controller looks :

def validateemail() {     def valid = false      if(params.email != null && params.email != "")     {         //count how many users have email - ignore case                     if (user.countbyemaililike(params.email) == 0)         {             valid = true         }     }      render valid  } 

but getting error follows :

    failure:  testvalidateemail(uk.co.litecollab.usercontrollerintegrationtests)  org.junit.comparisonfailure: expected:<[]false> was:<[true]false>     @ org.junit.assert.assertequals(assert.java:125)     @ org.junit.assert.assertequals(assert.java:147)     @ uk.co.litecollab.usercontrollerintegrationtests.testvalidateemail(usercontrollerintegrationtests.groovy:36) 

it seems failing on second assertion

when run 2 assertions individually, both pass, know data in assertion statements correct.

what doing wrong?


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -