locked
What is the Life Cycle of TestContext RRS feed

  • Question

  • Hi all,

    I'm using  VS2010 Premium and will implement VSTT (including CodedUITest)

    And there is a TestContext, I want to ask:

    1. When it would be instantiate and when it would be destroy?

    2. can I put object as property into TestContext? for example put object in TestMethod1 and get back the test method in method2?

    3. I also use OrderedTest to groups many TestMethod in order of test list (possibly in different TestProjects), I want to know whether we have Context for all test method with in one OrderedTest? If have Ordered Test Context, how about if we have add one OrderedTest (e.g. list1) to another OrderedTest (e.g. list2)?

    Thanks in advanced!

    Friday, March 29, 2013 4:07 PM

Answers

  • Hi TungLee,

    Thank you for posting in the MSDN forum.

    One thread for one issue, so if possible, I suggest you post the different issues in different threads.

    1. When it would be instantiate and when it would be destroy?

    As far as I know we don’t have to instantiate the TestContext type, see:

    Using the TestContext Class.

    TestContext Class.

    2. Can I put object as property into TestContext? For example put object in TestMethod1 and get back the test method in method2?

    Whether your test method1 is in the same project as test method2? It is not possible to access TestContext outside of TestClass.

    Reference:

    Accessing the TestContext outside of the CodedUI test project.

    About how we could use the TestContext, I think you could get useful information from Pankaj’s suggestion.

    How and where do I initialize testContext in ui test

    3. I also use OrderedTest to groups many TestMethod in order of test list (possibly in different TestProjects), I want to know whether we have Context for all test method with in one OrderedTest? If have Ordered Test Context, how about if we have add one OrderedTest (e.g. list1) to another OrderedTest (e.g. list2)?

    As far as I know, it doesn’t support it in ordered test, and the ordered test is just used for run test sequentially

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 1, 2013 6:56 AM
  • Thx Jack help and no problem on this item now...

    • Marked as answer by TungLee Wednesday, April 3, 2013 8:29 AM
    Wednesday, April 3, 2013 8:29 AM

All replies

  • Hi TungLee,

    Thank you for posting in the MSDN forum.

    One thread for one issue, so if possible, I suggest you post the different issues in different threads.

    1. When it would be instantiate and when it would be destroy?

    As far as I know we don’t have to instantiate the TestContext type, see:

    Using the TestContext Class.

    TestContext Class.

    2. Can I put object as property into TestContext? For example put object in TestMethod1 and get back the test method in method2?

    Whether your test method1 is in the same project as test method2? It is not possible to access TestContext outside of TestClass.

    Reference:

    Accessing the TestContext outside of the CodedUI test project.

    About how we could use the TestContext, I think you could get useful information from Pankaj’s suggestion.

    How and where do I initialize testContext in ui test

    3. I also use OrderedTest to groups many TestMethod in order of test list (possibly in different TestProjects), I want to know whether we have Context for all test method with in one OrderedTest? If have Ordered Test Context, how about if we have add one OrderedTest (e.g. list1) to another OrderedTest (e.g. list2)?

    As far as I know, it doesn’t support it in ordered test, and the ordered test is just used for run test sequentially

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 1, 2013 6:56 AM
  • Dear Jack,

    Sorry for multi issues in one post,

    and want to clarify one more things that, from your explain the life cycle of TestContext is within TestClass, hence different TestMethod share the same Context but one Context cannot be shared across different TestClass

    Do I get your point?

    Thanks again

    Wednesday, April 3, 2013 3:12 AM
  • Hi TungLee,

    I think you are right :)

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, April 3, 2013 8:26 AM
  • Thx Jack help and no problem on this item now...

    • Marked as answer by TungLee Wednesday, April 3, 2013 8:29 AM
    Wednesday, April 3, 2013 8:29 AM