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){
// ...
// }
}