querysim in script-style components

27 views
Skip to first unread message

Jim O'Keefe

unread,
Mar 5, 2014, 3:48:34 PM3/5/14
to mxu...@googlegroups.com
Does anyone write their tests in script-style (as opposed to tag-style) components? I'm trying to use injectMethod() where the injected method uses querySim to simulate a query. However, since the component is script-based, querySim is a function rather than custom tag. When the injected method is run it looks for the querySim function within the scope of the component under test. This seems crazy since I have to add a querySim function to every component I want to test this way. I can only come to one conclusion: I'm doing it wrong. How would other people approach this?

component extends="mxunit.framework.TestCase"{

public void function setUp() {
variables.CUT = new Something();
}

public void function testSomethingThatDoesSomethingWithAQuery(){
injectMethod( CUT, this, "getTestData", "getData" );
var some_thing = CUT.doSomethingWithAQuery();
assertEquals(some_thing,some_thing_else, "some_thing did not equal some_thing_else");
}

private query function getTestData(){
var fakeData = querySim(queryData = "
col1, col2, col3
data | data | data
data | data | data
data | data | data
");
return fakeData;
}

// private query function querySim(required string queryData){
// ...
// }
}

Carl Von Stetten

unread,
Mar 5, 2014, 4:13:46 PM3/5/14
to mxu...@googlegroups.com
Can you put the querySim function in a .CFM file and include it in each
component (as a mixin)? Or write a wrapper component with one function
(querySim), have that component extend mxunit.framework.TestCase, and
then have your test components extend your wrapper component?

Not sure if any of those would work, I'm just spit-balling.
-Carl V.


Jim O'Keefe

unread,
Mar 5, 2014, 5:01:16 PM3/5/14
to mxu...@googlegroups.com
Carl, thanks for giving it some thought. I'll take a look at your suggestions and give them a go.
Reply all
Reply to author
Forward
0 new messages