Get help with testing, discuss unit testing strategies etc.


Post by nuridesengin »

Hi there again.. I keep improve the test suite and each time needs some more structures for test suite.
I'm creating UI (GUI) test for my demo-app and doing lots of succession of actions. Therefore needs some idea!

I've created several methods in Test Class:
var formData = '#main-home #contentPanel #formData ';

Class('Siesta.Test.DataScreen', {
   isa: Siesta.Test.ExtJS,

methods: {
  clickAndType: function (fieldName, content, callback) {
            var t = this;

            t.chain(
                {click: formData + fieldName +' => .x-form-text', desc: 'Clicks on '+fieldName+' field'},
                {type: content, desc: 'Types '+ content +' field'},

                callback
            )
       }, 
       ...
and using this method in several test file:
describe('UI Testing: Submodule Data Screen', function (t) {

 t.it('Filling the form fields with dummy data', function (t) {
        var next = t.next;

        t.chain(
            {clickAndType: ['descfld[name=description]', 'Siesta Test 123']},
            ...
As you will notice clickAndType method's 'fieldName' arguments matches to 'descfld' in test file. It means 'Description Flied' which extended from 'Ext.form.field.Text'

The thing I'm using lots of clickAndType method for many different submodules and each time I had to change content (typed text) because of Database that I am using is protected for similar records.

Is there any way to tell Siesta read data from a JSON file? So I can easily change the data that will type to field on one file and implement for all other 29 test files?

Or any other idea for DRY?
Thanks in advice.
Last edited by nuridesengin on Wed Dec 13, 2017 12:48 pm, edited 2 times in total.

Post by nickolay »

Hi,

Sorry, not quite clear what you mean. Can you elaborate?

Post by nuridesengin »

well.. I'll try to make it easier, is it possible type method reads the data/content from a JSON file despite hard-code?

Post by nickolay »

No, thats not possible. You can however code that yourself if needed.

So is the goal to have a shared config value for a group of tests? And to access it from the test method?

Something like:
harness.start(
{
   myConfig : 'myValue',
    url : 'my_test.t.js'
}


testMethod : function () {
    return this.myConfig + 1
}

Post by nuridesengin »

Dear nikolay thanks for reply but actually I've reached my goal with has attribute of Joose :)

Maybe could help some other people therefore wanted to explain it. As I told I am using lots of iterative value to type on UI test files. So I've created test class' variables with has attribute such as mats adviced before. And now I just need to change data/value that will be using on Test Class and thats all :)

Here are some snippets:
var formData = '#main-home #contentPanel #formData ';

Class('Siesta.Test.DataScreen', {
   isa: Siesta.Test.ExtJS,

    has: {
       codeFldContent: 'Siesta Test CodeFld 0001',
       shortCodeFld: 'SC-01',
      descFld: 'Siesta Test Description 0001',

 methods: {
  clickAndType: function (fieldName, content, callback) {
            var t = this;

            t.chain(
                {click: formData + fieldName +' => .x-form-text', desc: 'Clicks on '+fieldName+' field'},
                {type: content, desc: 'Types '+ content +' field'},

                callback
            )
       }, 
       ...
and test file:
describe('UI Testing: Submodule Data Screen', function (t) {
 t.it('Filling the form fields with dummy data', function (t) {
        var next = t.next;

        t.chain(
            {clickAndType: ['codefld[name=code]', t.codeFldContent]},
            {clickAndType: ['shortcodefld[name=shortcode]', t.shortCodeFld]},
            {clickAndType: ['descfld[name=description]', t.descFld]}
        )
and works pretty well! Thanks a lot! ;) :)

Post by nickolay »

Cool-cool, yw!

Post Reply