DataDriven Testing feeding from other sources - Not Excel

View: New views
2 Messages — Rating Filter:   Alert me  

DataDriven Testing feeding from other sources - Not Excel

by Hernan Castagnola :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In order to feed my test cases in a dynamic way I am trying to feed it form a Class *Test*Provider
The purpose is the same as the dataDriven antTask but instead of feeding from an excel it feeds from from a Class.
The problem I am having is that I want to run all the tests not stopping when the first test fails.
The only way I found to do that was :

public class SeoHomepageTest extends WebtestCase {
   
    def provider = new SeoHomepageProvider()

    public void testSeoStructure() {
        provider.testCasesData.each(){test ->
            webtest("MetatagId: $test.metatagid Testing Title - Meta Description - MetaKeyword"){
                config (haltonerror: "false", haltonfailure: "false")
                ant.group description:"MetatagId: $test.metatagid" , {
                  Homepage.goTo(test.url, ant)
                  SeoVerifications.checkMetatags(test.title, test.metadescription, test.metakeyword, ant)
                }
            }
        }
    }

 
}

However this way when i see the results I see the same test several times, one per data injection.   Does anyone know if there is a way to do this in webtest:

public class SeoHomepageTest extends WebtestCase {
   
    def provider = new SeoHomepageProvider()

    public void testSeoStructure() {
     
            webtest("MetatagId: $test.metatagid Testing Title - Meta Description - MetaKeyword"){
                config (haltonerror: "false", haltonfailure: "false")
                  provider.testCasesData.each(){test ->           
                    ant.group description:"MetatagId: $test.metatagid" , {
                    Homepage.goTo(test.url, ant)
                     SeoVerifications.checkMetatags(test.title, test.metadescription, test.metakeyword, ant)
                }
            }
        }
    }

but telling webtest to continue with the next "test" if there is a step that fails.
Right now it stops the complete execution of the test when a setp fails.

something like this:

    public void testSeoStructure() {
     
            webtest("MetatagId: $test.metatagid Testing Title - Meta Description - MetaKeyword"){
                config (haltonerror: "false", haltonfailure: "false")
                  provider.testCasesData.each(){test ->           
                    ant.test description:"MetatagId: $test.metatagid" , {
                    Homepage.goTo(test.url, ant)
                     SeoVerifications.checkMetatags(test.title, test.metadescription, test.metakeyword, ant)
                }
            }
        }
    }


Thanks in advance


Hernan
 


Re: DataDriven Testing feeding from other sources - Not Excel

by Marc Guillemot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

you have probably to wrap your webtest call in a try / catch block.

Cheers,
Marc.
--
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com

Hernan Castagnola wrote:

> In order to feed my test cases in a dynamic way I am trying to feed it
> form a Class *Test*Provider
> The purpose is the same as the dataDriven antTask but instead of feeding
> from an excel it feeds from from a Class.
> The problem I am having is that I want to run all the tests not stopping
> when the first test fails.
> The only way I found to do that was :
>
> public class SeoHomepageTest extends WebtestCase {
>    
>     def provider = new SeoHomepageProvider()
>
>     public void testSeoStructure() {
>         *provider.testCasesData.each(){test ->*
>             webtest("MetatagId: $test.metatagid Testing Title - Meta
> Description - MetaKeyword"){
>                 config (haltonerror: "false", haltonfailure: "false")
>                 ant.group description:"MetatagId: $test.metatagid" , {
>                   Homepage.goTo(test.url, ant)
>                   SeoVerifications.checkMetatags(test.title,
> test.metadescription, test.metakeyword, ant)
>                 }
>             }
>         }
>     }
>
>  
> }
>
> However this way when i see the results I see the same test several
> times, one per data injection.   Does anyone know if there is a way to
> do this in webtest:
>
> public class SeoHomepageTest extends WebtestCase {
>    
>     def provider = new SeoHomepageProvider()
>
>     public void testSeoStructure() {
>      
>             webtest("MetatagId: $test.metatagid Testing Title - Meta
> Description - MetaKeyword"){
>                 config (haltonerror: "false", haltonfailure: "false")
>                *   provider.testCasesData.each(){test ->      *    
>                     ant.group description:"MetatagId: $test.metatagid" , {
>                     Homepage.goTo(test.url, ant)
>                      SeoVerifications.checkMetatags(test.title,
> test.metadescription, test.metakeyword, ant)
>                 }
>             }
>         }
>     }
>
> but telling webtest to continue with the next "test" if there is a step
> that fails.
> Right now it stops the complete execution of the test when a setp fails.
>
> something like this:
>
>     public void testSeoStructure() {
>      
>             webtest("MetatagId: $test.metatagid Testing Title - Meta
> Description - MetaKeyword"){
>                 config (haltonerror: "false", haltonfailure: "false")
>                *   provider.testCasesData.each(){test ->      *    
>                     *ant.test* description:"MetatagId: $test.metatagid" , {
>                     Homepage.goTo(test.url, ant)
>                      SeoVerifications.checkMetatags(test.title,
> test.metadescription, test.metakeyword, ant)
>                 }
>             }
>         }
>     }
>
>
> Thanks in advance
>
>
> Hernan
>  
>

_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest