locked
MSTest 10 shutting down application when run through command line RRS feed

  • Question

  • Why does MSTest, when invoked from the command line, shut down my application after completing a test.  There is no condition within the test explicitly telling it to do so.  

    If I run the same test through the Test List editor, application stays open as expected.  

    Any ideas?

    Wednesday, May 9, 2012 10:02 PM

Answers

  • HI knji,

    Glad to receive your reply.J

    I try to create a simple unit test, and then use it to open the Notepad, we could get the result like the following screen shot when we run it in the command line, then the process Notepad,ATAgent32.exe and MSTest.exe, they will be closed Automatically.

    As my understanding, it is similar to your test, you want to launch the application inside a method, but the mstest will be closed automatically, so the app will be closed too.

    So if we want to make the app be opened, my suggestion is that we could use the VS IDE to run the test. Based on my understanding, the MSTest couldn’t.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, May 16, 2012 3:10 AM
    Moderator

All replies

  • Once the mstest command has exited, it will exit the other commands invoked by it.

    You should see the same behavior with test list editor if you close visual studio.

    Thanks,

    Anuj


    http://www.anujchaudhary.com

    Thursday, May 10, 2012 2:38 AM
  • Hi Anuj,

    Thank you for your friendly assistance.

    Hi knji,

    Do you mean that you want to open other process with the MStest?

    If so, I think I have met the similar issue here, for example, hunter wanted to keep notepad opened after complete running unit test with mstest.

    Since the mstest is the parent process here and it will be closed after the test finished, so the process “notepad.exe” will be closed. We could check it with the MSFT tool “Process Explorer”.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, May 10, 2012 7:42 AM
    Moderator
  • This is not what I am observing.  If I close Visual Studio, application that was launched under a TestMethod remains open.

    Monday, May 14, 2012 2:21 PM
  • Do you mean that you want to open other process with the MStest?

    No.  I simply want my application to stay launched so that I can run other test that rely on it being open.  Otherwise, I have to relaunch application each time for every single test.

    Monday, May 14, 2012 2:23 PM
  • Thanks for the link.  It is indeed the same problem I have but none of the proposed solutions work in my case.  Running tests under testlist does not prevent application from being shutdown.  Sinceall I really want to do is automate application startup, I tried exposing a static method in my entry test class called StartOperatorInterface.  When I try to invoke this from another test class, Visual Studio throws the following error:

    at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindFromWindowHandle(IntPtr windowHandle)
    at Microsoft.VisualStudio.TestTools.UITesting.UITestControl..ctor(IntPtr windowHandle)
    at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.set_Process(Process value)
    at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.Start(ProcessStartInfo startInfo)
    --- End of inner exception stack trace
    ---
    at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.Start(ProcessStartInfo startInfo)
    at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest..ctor(String fileName, String alternateFileName, String arguments)
    at UITests.LoginCredentialsTest.StartOperatorInterface(String username, String password)
    in LoginCredentialsTest.cs: line 73
    at
    UITests.LogsViewTests.MyTestInitialize(TestContext context) in LogsViewTests.cs: line 61

    StartOperatorInterface method looks like this:

      public static void StartOperatorInterface(string username, string password)
            {
                var uimap = new AuthenticationWindowMap();
    
                var loginParams = uimap.SubmitLoginCredentialsParams;
                loginParams.UIUsernameBoxEditText = username;
                loginParams.UIPasswordBoxEditSendKeys = Playback.EncryptText(password);
          
                ApplicationUnderTest.Launch(@"C:\Program Files (x86)\myApp.exe");
                uimap.SubmitLoginCredentials();
            }

    • Edited by Klaus Nji Monday, May 14, 2012 5:09 PM
    Monday, May 14, 2012 3:05 PM
  • Hi knji,

    Glad to receive your reply.

    I simply want my application to stay launched so that I can run other test that rely on it being open. Otherwise, I have to relaunch application each time for every single test.

    Just to clear this issue, you want to run a test, and then run other test, but the other tests rely on the previous test, when you run it with VS IDE, it works well. When you run it with the mstest, this test could run well, but this test will be closed when it is finished.  So you couldn’t run other tests. Am I right?

    If so, as my understanding, the MSTest will be closed after the test finished, and the test will be closed too. If possible, I really suggest you could use the MSFT tool “Process Explorer” to check it. It will show the detailed information.

    Sincerely,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, May 15, 2012 6:16 AM
    Moderator
  • Hi knji,

    Glad to receive your reply.

    I simply want my application to stay launched so that I can run other test that rely on it being open. Otherwise, I have to relaunch application each time for every single test.

    Just to clear this issue, you want to run a test, and then run other test, but the other tests rely on the previous test, when you run it with VS IDE, it works well. When you run it with the mstest, this test could run well, but this test will be closed when it is finished.  So you couldn’t run other tests. Am I right?

    If so, as my understanding, the MSTest will be closed after the test finished, and the test will be closed too. If possible, I really suggest you could use the MSFT tool “Process Explorer” to check it. It will show the detailed information.

    Sincerely,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Correct.  What additional information will I get from Process Explorer?

    Anyways, I will trylaunching the application inside a method decorated with AssemblyInitialize attribute.  This way it is not part of any specific test.

    Tuesday, May 15, 2012 9:22 PM
  • HI knji,

    Glad to receive your reply.J

    I try to create a simple unit test, and then use it to open the Notepad, we could get the result like the following screen shot when we run it in the command line, then the process Notepad,ATAgent32.exe and MSTest.exe, they will be closed Automatically.

    As my understanding, it is similar to your test, you want to launch the application inside a method, but the mstest will be closed automatically, so the app will be closed too.

    So if we want to make the app be opened, my suggestion is that we could use the VS IDE to run the test. Based on my understanding, the MSTest couldn’t.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, May 16, 2012 3:10 AM
    Moderator
  • Hi knji,

    I mark the answer, please check it. If you need further assistance, please feel free to let us know.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, May 22, 2012 8:44 AM
    Moderator