locked
Data driven framework

    Question

  • Though Coded UI supports repetition of a test case based on data rows in CSV; is there a way to do it at a method level?

    e.g. Many sequences are data driven. Lets consider the this sample test case consisting of the following sequence -- 

    1) Login into application as data entry operator

    2) Create a customer record - basic details

    3) Enter family details (2 records - mother and father)

    4) Submit customer for verification

    5) Logout from application

    6) Login as verifier

    7) Verify customer

    And we are supposed to do this for say 3 customers. Now, using the existing data driven methodology provided by Coded UI, is it possible to achieve this? Or do I have to write my own framework to achieve this?

    Thursday, January 12, 2012 9:45 AM

All replies

  • I used to created (both in QTP and VS2010) tests similar to yours.  They were all working for me. See below if it would help you:

     

    In Uimap.cs, I would create:

    1) LoadDataSet(string dataFile) { Load the test data }

    2) LaunchTestSite() { launch IE or Firefox to the test site}

    3) public void Login(string uid, string pwd) { do the logon }

    4) public void CreatCust() { do the basic detail }

    5) public void PopFamDetail() { do the populate info }

    6) public void SubForVerif() { do the submit }

    7) public void Logout() { do the log out}

    8) public void VerifyCust()

     

    In test may help:

     

    For (i = 0, i <3, i++) {

    this.uimap.LaunchTestSite();

    this.uimap.LoadTestSet("theDataFile");

    this.uimap.Login(uid_from_theDataFile, pwd_from_theDataFile);

    ;;;

    ;;;;

    this.uimap.logout();

    this.uimap.Login(uid_from_theDataFile, pwd_from_theDataFile); // as verifier

    this.uimap.VerifyCust();

    }

     

    DataSet may contains:

    uid    , pwd ,  verifierUID, verifierpwd, and whatever data need to populate the field

    john1, pdoe,  vJohn1, vdoe, bla.....

    john2, pdoe,  vJohn2, vdoe, bla.....

    john3, pdoe,  vJohn3, vdoe, bla.....


    • Edited by LearnVSTest Thursday, January 12, 2012 1:25 PM
    • Proposed as answer by Ruiz Yi Tuesday, January 17, 2012 2:16 AM
    • Unproposed as answer by Apploader Tuesday, January 17, 2012 5:23 AM
    Thursday, January 12, 2012 1:25 PM
  • Thanks for the reply. This however, does not answer how to handle scenarios where you are required to repeat a particular method over several iterations within the same test case

    I have realized that (like in all tools) this is something that needs to be developed. I am in the process of developing a data driven framework which will cater to iterations at test as well as method level. Hoping that it will eventually work!

    Tuesday, January 17, 2012 5:25 AM
  • A method with attribute TestMethod is a test for framework. You can use inbuilt capabilities to create data driven tests at this methods level.

    According to the sequence you mentioned, EnterFamilyDetails is a method called from your test method and is not marked as TestMethod.

    What you can try is: Mark EnterFamilyDetails as TestMethod and provide datasource to it for data driven approach. Now call this testmethod from inside your main test.

    • Proposed as answer by TejasJ Tuesday, January 17, 2012 7:21 AM
    Tuesday, January 17, 2012 6:14 AM
  • This will mean that I will have to maintain data at a method level rather than test case level. Wouldn't this be a maintenance problem in the future? Like maintaining multiple data sheets/csv's for a single test case?

    The ideal framework would be the one which supports data driven at test level and has provisions to iterate multiple times at method level.

    Though there can be many permutations and combinations possible, I am proceeding with data driven two levels (parent i.e. test case and child i.e. method levels).

    Let me know your thoughts!

    Tuesday, January 17, 2012 6:23 AM
  • This will mean that I will have to maintain data at a method level rather than test case level. Wouldn't this be a maintenance problem in the future? Like maintaining multiple data sheets/csv's for a single test case?

    A method with TestMethod attribute is a test in this framework, and it allows multiple iterations using data driven approach at test level!

     

    The ideal framework would be the one which supports data driven at test level and has provisions to iterate multiple times at method level.

    Generally, multiple iterations are required at test case level rather than a test step level.

     -Tejas.

    • Proposed as answer by TejasJ Wednesday, January 18, 2012 5:12 AM
    Tuesday, January 17, 2012 6:57 AM
  • A method with TestMethod attribute is a test in this framework, and it allows multiple iterations using data driven approach at test level!

     

    I did understand this. But my argument was -- I have to mark each method as a test case to make it data driven. If this method (re-christened as a test case) is a part of a larger test case/scenario, then it will mean that I have to maintain multiple data sheets for that larger test case/scenario

     

    Generally, multiple iterations are required at test case level rather than a test step level.

    I differ; here a "step" is a method e.g. adding multiple relational data to a parent record

     

     

    Anyways, thanks for the support

    Tuesday, January 17, 2012 7:12 AM