mxunit and validation exceptions

WIthin my models I use "doValidate" functions that throw an exception of "validationExceptions", which you can read about here,  I am now getting into unit testing with MXUnit!!  So, I wanted to unit test my validation exceptions, therefore, i needed away to capture the exception and compare the number of validation errors returned to how many i expected.

The following is one of my mxunit test functions that trap the validationException error:

<cffunction name="testValidateForPassword2" displayname="password and verified password do not match" access="public" returntype="void">
    <cfscript>
        oFpsGTW = createObject("component","fps.model.FpsGTW").init(fpsServerURL="#variables.instance.fpsURL#");
       
        oFpsDTO = setupGoodDTO();
       
        //SET check not equal passwords
        oFpsDTO.setPassword("abcabc12");
        oFpsDTO.setVerifiedPassword("ababc12");
           
        actual = 0;
        expected = 1;
        try {
            oFpsGTW.validateForPassword(oFpsDTO);
            actual = 0;
        } catch (edu.psu.uao.exceptions.ValidationException e) {
            actual = e.length();
        }

       
        assertEquals(expected,actual,"Validation Routine Error");
    </cfscript>

</cffunction>





Comments

Popular posts from this blog

ColdFusion in an Enterprise Environment - Part 1 - Understanding how to use SubVersion (SVN)

coldfusion builder 2 extension not displaying browse button on type=projectdir

Being Thread Safe in Coldbox/Coldfusion