-1

I have 3 projects in my Visual Studio solution: 1 shared library project, 1 unit test project (mostly Selenium WebDriver tests), and 1 coded UI test project (I had a hard time combining my unit tests and coded UI tests into 1 project - so we have 2). I have a static class with a static property in the shared library project called Globals.Status.

I have one test case where it requires work done in both a broswer (the Selenium unit test) and a desktop app (the coded UI test). The Selenium unit test changes this static Status variable. The coded UI test (in the coded UI project) needs to read this updated Status variable. When I run these 2 tests consecutively, the variable is NULL when the coded UI test is invoked.

I have the coded UI test project referencing both the shared library project and the unit test project, but evidently this is not enough. What do I need to do to make this work?

Thanks for any insight!

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
AngieM
  • 735
  • 6
  • 27
  • 3
    Tests should be written so as not to be dependent on other tests performing an action. You should be able to select any single test in your suite, run it, and have it behave correctly. If you cannot, you should rethink the design of your test suite. – Kevin Jun 30 '16 at 18:48
  • I understand that concept. Yes ideally I'd combine both of these tests into 1 test. Unfortunately as said, I had a hard time putting both Selenium WebDriver and Coded UI test code into the same project. This one particular functional test requires some work to be done in a web browser (hence Selenium), and some other work afterward on a desktop app (hence Coded UI). – AngieM Jun 30 '16 at 19:10

2 Answers2

1

I guess that your UI test runs on new AppDomain. Each AppDomain creates own instances of all static variables.

What you can do is to move unit-test code into new class and execute it inside UI-test


p.s.

Tests should not depend on global state. Moreover, single test should not depend on other tests.

This will be especially tricky if ever want tests to execute in parallel

Here is good talk why global state is bad and what you can do about it: https://www.youtube.com/watch?v=-FRm3VPhseI

Gleb Sevruk
  • 494
  • 5
  • 9
  • Thanks for the advice and insight on the AppDomain. Yes I understand it wasn't the ideal design. I could not get Selenium WebDriver and Coded UI libraries to play nicely together in the same test project, so I had to resort to keeping them separate. I might have to try again when time allows to combine them into one. – AngieM Jun 30 '16 at 19:22
  • Move unit-test code to shared library project, and then you would be able to call it from UI-test without adding references to library's dependencies – Gleb Sevruk Jun 30 '16 at 19:31
1

You need to back your property with data that has been persisted outside of the application (more specifically, outside of the executing assembly's memory space).

There are a few reasonable ways you could do this. AppFabric Cache, Redis, or maybe Memcached come to mind.

Marcus
  • 166
  • 6
  • Thanks for this advice. I ended up saving this value in a text file to be read by the CUIT test. – AngieM Dec 13 '16 at 14:09