Get help with testing, discuss unit testing strategies etc.


Post by zombeerose »

As you guys probably already know, I have written a lot of tests so far ... 214 and counting. Early on, I decided against maintaining the list of test descriptors manually and instead, I chose to write a little server code that iterates the file system to build a nested structure of folders/files that corresponds directly with the groups/tests that I pass into Harness.start. This approach has one main limitation - I can't pass additional configs to the descriptors. I have ignored this problem but I'm hoping to find a solution with the help of the brains behind Siesta. :)

My first thought was to define a config file ("[test_name].t.config") alongside the test file ("[test_name].t.js") with additional options that I could parse/include via my server code. The problem is that options for the test are no longer contained in 1 spot. Maintainability is reduced & complexity is increased. While this could work, maybe there is a better option.

After discussing with a colleauge and getting a fresh perspective, we were wondering about extending the StartTest method to accept a second optional config. These options would be processed just as though they were passed into the test descriptor prior to execution. A brief example below:
StartTest(function (t) {
    t.done();
},{ //test-specific configs
    preload: [ ... ],
    expectedGlobals: [ ... ],
    ...
});
All thoughts & suggestions are welcome. Thanks for the hard work!

Post by nickolay »

This is an interesting idea. And should be not that hard to implement. In TODO for 1.0.8, thanks for suggestion!

I guess we'll also support the config object as the 1st argument - seems better to read the config for test before the test itself.

Post by zombeerose »

Thanks for your willingness to listen. You guys are awesome! Looking forward to it :)

Post by zombeerose »

Great work on 1.0.8!

I'm having one problem though. I'm trying to specify the config as the 1st arg but I'm not seeing the additional preload files in my network tab. Does the config in the test support all of the same options, such as 'alsoPreload'? Or am I doing something wrong?
StartTest({
    alsoPreload: ['...custom_src.js'],
    expectedGlobals: ['Ext','Custom']
},function(t) {
...
});

Post by nickolay »

Heh, seems the "alsoPreload" is a single exception from other options (`preload` will work). Fixing that.

Post by nickolay »

Should be fixed in the attachment.
Attachments
siesta-1.0.9-pre-lite.zip
(3.56 MiB) Downloaded 345 times

Post by zombeerose »

Perfect! Thanks for such a quick response :)

Post Reply