Compared to compiler-based languages like C++ or Java, JavaScript is quite straightforward. The syntax allows programmers to be imprecise here and there, and script execution isn't denied. Also, no type checks or function calls are analyzed before script execution. This behavior shifts bug detection away from compile time to execution time which makes testing at runtime (that is, unit tests) even more important as it is already done on compiled code.
The code below demonstrates this.
function getConvertedResult(importantData){ return importandData * 100.0; } exports.unitTesting = function( testInfo ){ var konvValue = getKonvertetResult(); var result = 500.4 * konvValue; }
In this example, a programmer created a function called getConvertedResult and probably forgot to pass the required function parameter. Later on, the function was renamed, but the function call wasn't updated.
All this is OK for JavaScript as long as the script isn't executed. Although there's a "compile" option available at the development environment, all it does is check the JavaScript syntax, and it is fine in the example above. Changing the first function call to the example below (it misses the function declaration), would break the JavaScript syntax. This error could be detected before runtime.
getConvertedResult(importantData){ return importandData * 100.0; }
Unit testing with Advanced Toolpath Utility
Every buildstyle project should implement the unit test callback function. All unit tests should be part of this function at the main JavaScript (probably main.js).
exports.unitTesting = function( testInfo ){ }
Running the unit tests from within the development environment, will call this JavaScript method. The test information structure that is passed to the function stores all test results and checks the results in the end. An empty information structure fails the test procedure. A non-empty structure with only tests that have passed creates a positive unit-test result.
For buildstyles with no unit tests, it is recommended to at least implement this:
exports.unitTesting = function( testInfo ){ // testname, additional info, test passed testInfo.addTest( 'DummyTest', 'Dummy', true); }
This implementation produces a positive feedback if unit testing is started.
Starting unit tests
The development environment offers these methods for starting unit tests.
By simply pressing the button or menu entry.


By using the script console.

By activating the unit test feature at the buildstyle execution.

The test result is displayed in both the command interface and in the Build Style Log window.
![]() |
![]() |
![]() |