Search code examples
c#visual-studioxamarin.formsnunitxamarin.uitest

NUnit UITest run in sequence of one another


Question:

I have a Xamarin.UITest project setup with NUnit framework. I know that using [Test, Setup] provides me the ability to have a setup test that is ran before each test. I was wondering if there is a way to have my [Test, Setup] run before each test, but then have the tests that follow pickup on the exact page where the setup left off?

Why:

I have about 6 or 7 UITests that test a specific page within our application. I am trying to minimize redundancy, so any automation that navigates me to that page (I believe) should be done once in a separate method; i.e: the setup method.

I have searched S.O. as well as NUnit.org, I just don't know how to do my specific ask. Please let me know! Thanks!


Solution

  • Apoligies for a 2nd answer, but it appears you want to do:

    public class MyTest
    {
        [Test]
        public void Test1()
        {
            Setup1();
            DoSomeTests();
        }
    
         [Test]
        public void Test2()
        {
            Setup1();
            Setup2();
    
            DoSomeTests();
    
        }
    
        private void Setup1()
        {
        }
        private void Setup2()
        {
    
        }
    
    
     }