how can i test insert, update and delete queries ?

75 views
Skip to first unread message

Mohammed Suleman khan

unread,
Jan 23, 2014, 3:47:38 PM1/23/14
to mxu...@googlegroups.com
Hi,
I am new to MXUnit testing, I did basic examples which shown in wiki and i did test on some real time stuffs like queries. I was trying to test insert, update, and delete query i don't know what to do ? I would be thankful if anyone let me know what i have to do to test DML queries ?

this is my testing stub to test the insert query....I got the error saying mxunit error.

<cffunction name="testCreateSite">
        <cfset var createSite = createObject("component","admin.services.sites") />
        <cfset makepublic(createSite,"_create")>
        <cfset createSite.setDSN("regionscms") />
        <cfset createSite.setLogger(new org.regionscms.utils.logger()) />
        <cfset var result = createSite._create("Mxunit","home.com","sul...@yahoo.com") />
        <cfset assertTrue(IsQuery(result)) />
  </cffunction>

 I am using fw1 framework  all my component are inside the services folder.

Thanks

Marc Esher

unread,
Jan 24, 2014, 8:07:42 AM1/24/14
to mxu...@googlegroups.com
Let's back up a bit.

First, are you able to write a simple test, such as

function testTest() {

  assertTrue(true);

}

And not get an error?

Second, when you run your test, what specific error do you get?



--
You received this message because you are subscribed to the Google Groups "mxunit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mxunit+un...@googlegroups.com.
To post to this group, send email to mxu...@googlegroups.com.
Visit this group at http://groups.google.com/group/mxunit.
For more options, visit https://groups.google.com/groups/opt_out.

Message has been deleted

Marc Esher

unread,
Feb 3, 2014, 8:36:34 AM2/3/14
to mxu...@googlegroups.com
It's hard for me to get a full sense of the problem here b/c the code is in isolation. assertTrue() would indeed fail if the result is false (i.e. "result" is not a query).

Can you post a completely standalone version? Is your test component extending mxunit.framework.TestCase? Are you running that test in a browser?

Are you following a getting-started instruction, such as http://wiki.mxunit.org/display/default/First+Test+Case


On Fri, Jan 24, 2014 at 9:10 AM, Mohammed Suleman khan <salmank...@gmail.com> wrote:
i did the simple things and it works fine..........i have done testing on list and some stuffs it is quite fine for me. i was trying to test insert queries got error Mxunit failure

this is what i did

<cffunction name="testCreateSite">
        <cfset var createSite = createObject("component","admin.services.sites") />
        <cfset makepublic(createSite,"_create")>
        <cfset createSite.setDSN("regionscms") />
        <cfset createSite.setLogger(new org.regionscms.utils.logger()) />
        <cfset var result = createSite._create("Mxunit","home.com","sul...@yahoo.com") />
        <cfset assertTrue(IsStruct(result)) />
    </cffunction>

Stack Trace of the error.

mxunit test failure at mxunit.framework.assert_cfc$cf.udfCall1(/mxunit/framework/Assert.cfc:155):155 at mxunit.framework.assert_cfc$cf.udfCall(/mxunit/framework/Assert.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:189):189 at railo.runtime.tag.Invoke.doFunction(Invoke.java:217):217 at railo.runtime.tag.Invoke.doEndTag(Invoke.java:184):184 at mxunit.framework.assert_cfc$cf.udfCall2(/mxunit/framework/Assert.cfc:377):377 at mxunit.framework.assert_cfc$cf.udfCall(/mxunit/framework/Assert.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.call(UDFImpl.java:207):207 at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:704):704 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:722):722 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1518):1518 at org.regionscms.tests.componenttest_cfc$cf.udfCall2(/org/regionscms/tests/componentTest.cfc:127):127 at org.regionscms.tests.componenttest_cfc$cf.udfCall(/org/regionscms/tests/componentTest.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:194):194 at railo.runtime.ComponentImpl._call(ComponentImpl.java:625):625 at railo.runtime.ComponentImpl._call(ComponentImpl.java:507):507 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1748):1748 at railo.runtime.tag.Invoke.doComponent(Invoke.java:203):203 at railo.runtime.tag.Invoke.doEndTag(Invoke.java:176):176 at mxunit.framework.testcase_cfc$cf.udfCall2(/mxunit/framework/TestCase.cfc:141):141 at mxunit.framework.testcase_cfc$cf.udfCall(/mxunit/framework/TestCase.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:194):194 at railo.runtime.ComponentImpl._call(ComponentImpl.java:625):625 at railo.runtime.ComponentImpl._call(ComponentImpl.java:507):507 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1752):1752 at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:748):748 at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1528):1528 at mxunit.framework.decorators.dataproviderdecorator_cfc$cf.udfCall1(/mxunit/framework/decorators/DataProviderDecorator.cfc:31):31 at mxunit.framework.decorators.dataproviderdecorator_cfc$cf.udfCall(/mxunit/framework/decorators/DataProviderDecorator.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.call(UDFImpl.java:207):207 at railo.runtime.ComponentImpl._call(ComponentImpl.java:624):624 at railo.runtime.ComponentImpl._call(ComponentImpl.java:507):507 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1735):1735 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:722):722 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1518):1518 at mxunit.framework.testsuiterunner_cfc$cf.udfCall1(/mxunit/framework/TestSuiteRunner.cfc:105):105 at mxunit.framework.testsuiterunner_cfc$cf.udfCall(/mxunit/framework/TestSuiteRunner.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.call(UDFImpl.java:207):207 at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:704):704 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:722):722 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1518):1518 at mxunit.framework.testsuiterunner_cfc$cf.udfCall1(/mxunit/framework/TestSuiteRunner.cfc:55):55 at mxunit.framework.testsuiterunner_cfc$cf.udfCall(/mxunit/framework/TestSuiteRunner.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.call(UDFImpl.java:207):207 at railo.runtime.ComponentImpl._call(ComponentImpl.java:624):624 at railo.runtime.ComponentImpl._call(ComponentImpl.java:507):507 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1735):1735 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:722):722 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1518):1518 at mxunit.framework.testsuite_cfc$cf.udfCall1(/mxunit/framework/TestSuite.cfc:131):131 at mxunit.framework.testsuite_cfc$cf.udfCall(/mxunit/framework/TestSuite.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.call(UDFImpl.java:207):207 at railo.runtime.ComponentImpl._call(ComponentImpl.java:624):624 at railo.runtime.ComponentImpl._call(ComponentImpl.java:507):507 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1735):1735 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:722):722 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1518):1518 at mxunit.framework.testcase_cfc$cf.udfCall2(/mxunit/framework/TestCase.cfc:156):156 at mxunit.framework.testcase_cfc$cf.udfCall(/mxunit/framework/TestCase.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.call(UDFImpl.java:207):207 at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:704):704 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:722):722 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1518):1518 at mxunit.framework.testcase_cfc$cf.udfCall3(/mxunit/framework/TestCase.cfc:199):199 at mxunit.framework.testcase_cfc$cf.udfCall(/mxunit/framework/TestCase.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:92):92 at railo.runtime.type.UDFImpl._call(UDFImpl.java:303):303 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:194):194 at railo.runtime.ComponentImpl._call(ComponentImpl.java:625):625 at railo.runtime.ComponentImpl._call(ComponentImpl.java:515):515 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1760):1760 at railo.runtime.ComponentSpecificAccess.callWithNamedValues(ComponentSpecificAccess.java:139):139 at railo.runtime.ComponentPage.callWDDX(ComponentPage.java:615):615 at railo.runtime.ComponentPage.call(ComponentPage.java:186):186 at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:885):885 at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:837):837 at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:208):208 at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:18):18 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2182):2182 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2149):2149 at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:332):332 at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722):722 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224):224 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169):169 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472):472 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168):168 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98):98 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407):407 at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579):579 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307):307 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146):1146 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615):615 at java.lang.Thread.run(Thread.java:701):701
Reply all
Reply to author
Forward
0 new messages