Brent
06/24/2024, 11:20 PMbeforeAll()
to instantiate the component. My question is what is recommended for initializing an environment (populating and setting up needed global settings. i.e. found in Application.cfc) in the tests?
Example:
component extends="testbox.system.BaseSpec" {
function beforeAll(){
// I could setup things like this, but is there a better way?
application.dsn = "myDsn";
// Is there a way to reference what is set in Application.cfc - Can I just reuse what is already set in Application.cfc? (there are a lot of global vars set...)
// should I replicate Application.cfc var settings in the tests/Application.cfc (this feels wrong and maintenance problem prone)
// instantiate my component with necessary dependencies injected
myComponent = createObject('component', 'some.cool.Component').init(
dsn=application.dsn,
someKey=application.someKey,
otherInjectedComponent=application.instantiatedOtherComponent,
//etc....
)
}
function afterAll(){
// Do I need to do anything here?
}
describe("component tests", function() {
it("can compile", function() {
// referencing the component instance I created in beforeAll
expect(myComponent).toBeComponent();
});
});
}
seancorfield
application
scope?seancorfield
application
scope for that...Brent
06/24/2024, 11:36 PMBrent
06/24/2024, 11:38 PMseancorfield
Brent
06/24/2024, 11:38 PMseancorfield
application.* = ...;
stuff from Application.cfc
to an include file and include it in both the Application.cfc
and the test file. Awful, but it would at least keep things in sync for now.seancorfield
Brent
06/24/2024, 11:42 PMseancorfield
seancorfield
Brent
06/24/2024, 11:50 PMseancorfield
Brent
06/24/2024, 11:55 PMseancorfield
Brent
06/24/2024, 11:57 PMseancorfield
di1
repo README)Brent
06/25/2024, 12:05 AMseancorfield
loadListener
approach and explicitly adding any non-conventional mappings there as you need them. That way you can do things incrementally.Brent
06/25/2024, 12:07 AMgavinbaumanis
06/25/2024, 1:49 AMBrent
06/25/2024, 4:13 AMgavinbaumanis
06/25/2024, 4:43 AMBrent
06/25/2024, 11:26 AM