0

I have setup siesta lite to test my ExtJs 4 application. I want to run a test depending upon the value of window.xxx and window.yyy of my application. So if xxx= 1 and yyy= 'xyz', I want to run a particular test file lets say test1.js. I read the siesta documentation but I couldn't find anything.

Here is my code:

var harness = new Siesta.Harness.Browser.ExtJS()
window.harnessObj = harness;
harness.configure({
    title              : 'My Tests',
    preload : [
       /* '../resources/extjs-4.2/resources/css/ext-all.css',
        '../resources/extjs-4.2/ext-all-debug.js',
        '../resources/json/textLabels.js',*/
    ]
});

harness.start(
    {
        group: 'Unit Tests',
        pageUrl: '../index.html?unittest',
        items:
        [
            {
                title : 'PopUpWindow',
                url : 'tests/PopUpWindow.js'
            },
            {
                title : 'S_0-R_PjM',
                url : 'tests/S_0-R_PjM.js'
            }
        ]
    }
);

harness.on('testsuitestart', function (event, harness)
    {
        //debugger;
        console.log('I fucking love Testing')
    }, this, 
    { single : true }
)

I want to run 'tests/S_0-R_PjM.js' inside 'tests/S_0-R_PjM.js' depending upon the certain value of windows object which is set by my application index.html.

My index.js looks like this: // also supports: startTest(function(t) {

describe(function(t) {
    t.diag("PfalzkomApp Loading Test");

    t.ok(Ext, 'ExtJS has been loaded');
    t.ok(Ext.Window, 'ExtJS.Window has been loaded');
    t.ok(window.xxx, loaded with value :' + window.xxx);
    t.ok(window.yyy, loaded with value :' + window.yyy);

    var status = parseInt(window.xxx);
    var role = window.yyy;

    switch(status) {
     case 111:
        switch(role)
        {
            case "abc":
                debugger;
                // How to load another test file(tests/S_0-R_PjM.js) and start that test here !!!    
                break;
            case "def":

                break;
        }
    }

    t.done();
})

// Updated Question - Sample code which I want to put inside another test file and call it when required

StartTest(function(t) {
    t.diag("Case: Status: Neu and Role:PjM ");
    //S_0-R_PjM
    t.ok(Ext, 'ExtJS has been loaded');

    t.done();   // Optional, marks the correct exit point from the test
})

Can some one guide me?

Abdul Rehman Yawar Khan
  • 1,088
  • 3
  • 17
  • 40

1 Answers1

1

I am not aware of any build-in function in the harness file which could help you achieve that.

But if you really doesn't want to have all your code in one file you can use TestClass - with this you can have your code in the different files.

http://www.bryntum.com/docs/siesta/#!/guide/extending_test_class

Keep in mind that this will not load different "test". You are still going have 1 test file in your Siesta interface but it will execute the different code based on your if statement.

pagep
  • 3,488
  • 1
  • 26
  • 47
  • thank you for your response. But I am still not able to achieve my goal. Can you give me an example that how I can put this code(updated Code Sample in Question) in a sub test class and call it when required? – Abdul Rehman Yawar Khan Mar 15 '16 at 09:15