Discuss anything related to web development but no technical support questions


Post by sonika »

My project is web project(say A), in that i have created 1 more Siesta web project where I have kept all the test scripts.
I want to keep my button specification like style, height etc in a singleton constant file in the Siesta project. When I try to access this constant file from the testscript in siesta, it gives file not found error as it tries to
find the file in the Web Project(A) instead of Siesta project.
Request you to please suggest..

Thanks
Sonika

Post by mats »

Maybe you have wrong URL somewhere? Can you provide a simple test case showing what is going wrong?

Post by sonika »

/*suppose this is class A containing variable**************************************************************************************/
Class('appTesting.com.adaptiveAnalytics.reqSpecification.CssSpecification', {
                isa     : Siesta.Test.ExtJS,
                    
                    has     : {
                        // will be initialized with atomic values
                        attribute1    : null,
                        attribute2    : 'foo',
                        attribute3    : 11,
                        
                    }

});


/* This is class B containing method login**********************************************************************************************/
Class('appTesting.com.adaptiveAnalytics.utils.LoginApp', {

isa     : Siesta.Test.ExtJS,

methods: {
        login : function (user, pw, next) {
            var me = this;
            this.chain(                               
              { waitFor : 'componentVisible', args : '#loginButton' },
                function(next) {
                    me.cq1('#user').setValue(user);
                    me.cq1('#pwd').setValue(pw);
                    next();
                },

                { action : 'click', target : '>> #loginButton' },
                { waitFor : 'xType', args : 'menu'},

                next
            );
        }
    }
});

/* there is 3rd class C which will access both class A and Class B by calling there method and attribute*********************************************************************/

StartTest(function(t) 
{
t.chain(                 
function(next)
{
                                                alert(t.attribute1);   /* from class A */
                                                t.login('admin', 'test@123',next); /* from Class B*/
},
);                    
});


In order that Class C can use variable and method of Class A and Class B we have included the path in Harness.js


Harness.configure({
    title     : 'Sencha Touch 2 samples',

    enableCodeCoverage : true,
  testClass   : appTesting.com.adaptiveAnalytics.reqSpecification.CssSpecification,

   transparentEx:false, 
    preload : [
         "./appTesting/resources/css/sencha-touch.css",
         "./appTesting/resources/sencha-touch-all-debug.js",
         "appTesting.com.adaptiveAnalytics.reqSpecification.CssSpecification",   /* This is Class A*/
          " appTesting.com.adaptiveAnalytics.utils.LoginApp"                     /*This is Class B*/
      ],

 keepNLastResults    : 2

});
Currently we have given Class A i.e "appTesting.com.adaptiveAnalytics.reqSpecification.CssSpecification" in testClass. so Class C will access the member/attribute of Class A.
if we give Class B i.e " appTesting.com.adaptiveAnalytics.utils.LoginApp " in testClass . then Class C will access attribute/method of Class B.

How can Class C access the attribute and method of both Class A and Class B

Post by nickolay »

Hi,

1) I see you include sencha-touch files in your preload, but your test classes inherits from Siesta.Test.ExtJS? Perhaps they should inherit from Siesta.Test.SenchaTouch?

2) Do not include your test classes files in the preloads. Treat those files as your extensions for Siesta, and thus include them on the harness page, right after the "siesta-all.js".

3) If I understood you correctly, you have 2 test classes, both of which inherit from Siesta.Test.ExtJS and you would like to re-use some methods from both classes in the 3rd test class. To do that, move such methods to the Joose role (role is something similar to mixin), and then consume that role in appropriate classes, using the "does" keyword.

For example:
Role('ReusableMethods', {
    
    has : {
        reusableAttribute1 : null
    },
    
    
    methods : {
        reusableMethod1 : function () {
        },
        
        reusableMethod2 : function () {
        }        
    }
})

Class('TestClass1', {
    isa     : Siesta.Test.ExtJS,
    
    does    : ReusableMethods,
    
    methods : {
        methodForTestClass1 : function () {}
    }
})

Class('TestClass2', {
    isa     : Siesta.Test.ExtJS,
    
    does    : ReusableMethods,
    
    methods : {
        methodForTestClass2 : function () {}
    }
})
Both TestClass1 and TestClass2 will have the "reusableMethod1" and "reusableMethod2" from the consumed role.

Post by sonika »

Hi,

The example given by you in last post having
one class 'ReusableMethods' which contains variable and method .
two class 'TestClass1' and 'TestClass2' uses the method defined in class 'ReusableMethods'.

But we need to implement suppose there is
2 class 'TestClass1' and 'TestClass2' both have their own variable and methods defined , then
3rd class suppose 'MasterClass' need to call the method defined in TestClass1 as well as TestClass2.

Then how can masterClass can call the methods of TestClass1 and TestClass2

Post by mats »

But this is exactly what was described above. A Class can consume any number of Roles.
Class('TestClass1', {
    isa     : Siesta.Test.ExtJS,
   
    does    : [
         Role1,
         Role2
    ],

    has      : {
        foo : 'bar' 
    },

    methods : {
        methodForTestClass1 : function () {}
    }
})

Post by sonika »

Hi Mats,

Thanks for the reply.

There is one issue that when we use the does keyword in the code it is not able to recognize the Role file ReusableMethods and gives an exception "Uncaught ReferenceError: ReusableMethods is not defined " on the below line.
does: [ReusableMethods],

It seems may be there is some configuration entry required by which the siesta framework can recognize the ReusableMethods class which we are missing.
Request you to please assist.

Post by mats »

Have you included the file where ReusableMethods is defined? It should be included in your Siesta HTML page. See our examples/ folder for guidance too.

Post by sonika »

Yes, I have included the file in the HTML page. I can see the file is getting loaded, but it is still throwing the exception at the does statement.
Thanks

Post by mats »

Please upload a test case showing your issue.

Post Reply