I am new to testbox. I have an existing CF app in ColdFusion Builder 2016 on Windows 7 and I’d like to create some unit tests that I can run by either browsing to a url or running from a command line.
I am also somewhat new to ColdFusion Builder since I code most of the time in Visual Studio/C#/IIS).
I have a folder in my app called UnitTests. I’d like to put a bunch of unit tests in that folder and easily run them and report on them using testbox. How do I do that? Here are some details with associated questions:
I looked at Running Tests at https://testbox.ortusbooks.com/content/primers/bdd/running_tests.html but I am missing info on setting up folders and paths and coordinating the running of tests with my app.
For instance, I saw that the C:\Users\myUserName.CommandBox folder was set up when I ran box.exe after downloading it. This is outside my doc root which is at C:\ColdFusion2016\cfusion\wwwroot .
My project is contained under that folder, e.g. C:\ColdFusion2016\cfusion\wwwroot\MyWebProject . The UnitTests folder is under that at C:\ColdFusion2016\cfusion\wwwroot\MyWebProject\UnitTests .
I assume that I will need to create a Server Setting Mapping (virtual directory) to a folder where I can launch the testbox runner file using the CFIDE, correct?
I have created a unit test file called SimpleTest.cfc (docs don’t give an example of what to name the file but I assume it should be a .cfc) that looks like the following and I put it in the UnitTests folder:
component extends=“testbox.system.BaseSpec”{
// executes before all suites-setup
function beforeAll(){}
// executes after all suites-tear down
function afterAll(){}
// All suites go in here
//add the unit tests here
function run( testResults, testBox ){
UnitTest1();
UnitTest2();
…
});
}
UnitTest1() {//eventually move this to separate file in its own folder for tests in the same category of tests
describe(“Unit Test 1”, function() {
it(“contains spec with an awesome expectation”,
function() {
expect( true ).toBeTrue();
});
})
};
UnitTest2() {//eventually move this to separate file in its own folder for tests in the same category of tests
describe(“Unit Test 2”, function() {
it(“contains spec with an awesome expectation”,
function() {
expect( true ).toBeTrue();
});
})
};
I tried running the above CFC in the browser but it can’t seem to find testbox.system.BaseSpec . I also tried it with extends=“testbox.system”. How do I make sure it can find the required component(s)?
How do I configure things so I can run the unit tests in SimpleTest.cfc and see the results in the browser and from CommandBox?
Since users will often have existing CFM apps that they want to add testbox tests to, ideally the docs would contain a CF Builder sample setup where your app and testbox locations are very different and it would walk you through how to setup and run the test.
Right now, I just see bits and pieces that I am trying to weave together. If something like this exists, could you please provide a url for it?
Thanks,
Steve Shier