I would like to know what are the best practices for calling model components in Testbox. I hoped they could simply be injected via Wirebox, but it does not seem to be the case:
I created some mappings in Wirebox as follows:
map(“Mail”).to(“models.utils.Mail”);
map(“Carrier”).to(“models.crd.Carrier”);
map(“Geozone”).to(“models.crd.Geozone”);
map(“GeozoneSVC”).to(“models.crd.GeozoneSVC”);
The mappings work fine when injecting those components in any of my services, meaning for example, I inject the mail component as “Mail” in a service component and it is properly loaded.
When it comes to Testbox, I can no longer rely on the Wirebox mappings. For example, when I mock components in Testbox, the component is successfully loaded only if I fully qualify the path to the component, like that:
/*********************************** LIFE CYCLE Methods ***********************************/
function beforeAll(){
super.beforeAll();
// Create the Geozone service to test, do not remove methods, just prepare for mocking
geozoneService = createMock(“models.crd.GeozoneSVC”);
// Mock the entity bean
mockBean = createEmptyMock(className=“models.crd.Geozone”);
// do your own stuff here
}
function afterAll(){
// do your own stuff here
super.afterAll();
}
/*********************************** BDD SUITES ***********************************/
If the path ever changes, it is bad news. Any suggestions before I start writing a whole lot more tests … Thanks