/// <summary>
        /// Installs testing software if necessary, initializes the test browser and executes all tests for the system.
        /// Returns a non-zero code if a failure was encountered when running a test. It is possible to have a zero return code when there is a failure if the
        /// failure occurs before the tests begin to run, for example.
        /// </summary>
        public static int RunAllWebTestsForSystem()
        {
            WebTester webTester = null;
            try {
                OneTimeInstall.InstallSeleniumServiceIfNecessary();

                // NOTE: Moving selenium initialization here instead of setupBrowser will simplify things and make it so we don't have to create the WebTester reference too early.
                // We also won't need to hold a selenium member variable.

                Console.WriteLine( "Executing web tests..." );
                webTester = new WebTester();

                // Only do this if the intermediate log on didn't fail.
                if( Environment.ExitCode == 0 ) {
                    foreach( var testClass in
                        Assembly.GetCallingAssembly().GetTypes().Where( t => t.GetCustomAttributes( typeof( TestFixtureAttribute ), true ).Any() ).OrderBy( tc => tc.Name ) )
                        webTester.executeTest( testClass );
                    Console.WriteLine( "Web tests complete." );
                }
            }
            catch( Exception e ) {
                // NOTE: After we eliminate environment.exit code setting, try to wrap this method in standard exception handling instead.
                TelemetryStatics.ReportError( e );
            }
            finally {
                if( webTester != null )
                    webTester.teardown();
            }

            return Environment.ExitCode;
        }
Пример #2
0
        /// <summary>
        /// Installs testing software if necessary, initializes the test browser and executes all tests for the system.
        /// Returns a non-zero code if a failure was encountered when running a test. It is possible to have a zero return code when there is a failure if the
        /// failure occurs before the tests begin to run, for example.
        /// </summary>
        public static int RunAllWebTestsForSystem()
        {
            WebTester webTester = null;

            try {
                OneTimeInstall.InstallSeleniumServiceIfNecessary();

                // NOTE: Moving selenium initialization here instead of setupBrowser will simplify things and make it so we don't have to create the WebTester reference too early.
                // We also won't need to hold a selenium member variable.

                Console.WriteLine("Executing web tests...");
                webTester = new WebTester();

                // Only do this if the intermediate log on didn't fail.
                if (Environment.ExitCode == 0)
                {
                    foreach (var testClass in
                             Assembly.GetCallingAssembly().GetTypes().Where(t => t.GetCustomAttributes(typeof(TestFixtureAttribute), true).Any()).OrderBy(tc => tc.Name))
                    {
                        webTester.executeTest(testClass);
                    }
                    Console.WriteLine("Web tests complete.");
                }
            }
            catch (Exception e) {
                // NOTE: After we eliminate environment.exit code setting, try to wrap this method in standard exception handling instead.
                TelemetryStatics.ReportError(e);
            }
            finally {
                if (webTester != null)
                {
                    webTester.teardown();
                }
            }

            return(Environment.ExitCode);
        }