Issues running Unit Test after upgrading solution to 8.2.1

Best practices, code snippets for common functionality, examples, and guidelines.
XXXW0
Posts: 1
Joined: Sat Sep 15, 2018 12:24 am

Issues running Unit Test after upgrading solution to 8.2.1

Post by XXXW0 » Mon Sep 17, 2018 8:07 pm

Greetings,

I have previously used Ranorex 8.1.2 to create a Unit Test that calls my Ranorex project in C#.

After upgrading my Ranorex project to 8.2.1, and the corresponding Ranorex references in my Unit Test I get an error that might be indicating that I'm missing something, or not setting something up correctly.

Specifically I get an Object reference not set to an instance of an object and the stack trace links to the following:
RanorexReportError.PNG
RanorexReportError.PNG (140.83 KiB) Viewed 110 times
The following is my Unit Test

Code: Select all

public void GoogleCats_RunApplication_ApplicationRan()
        {
            int error;
            try
            {
                Ranorex.Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;

                string pathToExecutable = "";
                var executableName = "GoogleCats.exe";

            #if DEBUG
                pathToExecutable = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), executableName);
            #endif

                string testCase = TestContext.Properties["TestCase"].ToString();

                var param = $"{pathToExecutable} {testCase}";
                error = TestSuiteRunner.Run(typeof(GoogleCats.Program), param);

                if (error != 0)
                {
                    Ranorex.Report.Failure("Failure.");
                    throw new RanorexException("Test has failed.");
                }
                Assert.AreEqual(error, 0);
            }

            catch(Exception e)
            {
                Report.Error($"Unexpected exception occurred: {e.ToString()}");
                error = -1;
                throw e;
            }
        }
Is there something I'm missing, are Unit Tests done differently in C# with Ranorex 8.1.2?

To clarify my project runs fine in Ranorex Studio, just not in my Unit Test.

User avatar
Vega
Posts: 109
Joined: Mon Jul 11, 2016 2:15 pm

Re: Issues running Unit Test after upgrading solution to 8.2.1

Post by Vega » Wed Sep 19, 2018 5:07 am

I took a look at the release notes (specifically breaking changes) and did not see anything standing out that may affect your unit test. I did have a similar issue which was resolved by this thread, so it may be worth taking a look at: problem-with-ranorex-core-resolver-in-8-0-0-t11808.html

Let us know if you make any progress!