示例#1
0
    /**
     * Initialize class resources.
     */
    void Start()
    {
        // Create test suite
        TestSuite suite = new TestSuite();

        // For each assembly in this app domain
        foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies())
        {
            // For each type in the assembly
            foreach (Type type in assem.GetTypes())
            {
                // If this is a valid test case
                // i.e. derived from TestCase and instantiable
                if (typeof(TestCase).IsAssignableFrom(type) &&
                    type != typeof(TestCase) &&
                    !type.IsAbstract)
                {
                    // Add tests to suite
                    suite.AddAll(type.GetConstructor(new Type[0]).Invoke(new object[0]) as TestCase);
                }
            }
        }

        // Run the tests
        TestResult res = suite.Run(null);

        // Report results
        Unity3D_TestReporter reporter = new Unity3D_TestReporter();

        reporter.LogResults(res);
    }
        /**
         * Main entry point.
         * Runs unit tests for the unit testing framework.
         *
         * @param args, array of string arguments.
         */
        static void Main(string[] args)
        {
            try
            {
                // Create the test suite
                TestSuite suite = new TestSuite();

                // Add tests to the test suite
                suite.AddAll((TestCase) new Weapons_Test());

                // Run the tests
                TestResult result = suite.Run(null);

                // Report test results
                TestReporter reporter = new TestReporter();
                reporter.LogResults(result);
            }
            catch (Exception e)
            {
                // Log uncaught exceptions
                System.Console.WriteLine(e.ToString());
            }

            // Set a break point here for testing to examine console output
            //int pause = 0;
        }
示例#3
0
    protected void TestCategory(TestCase _category, string _prefix)
    {
        TestSuite suite = new TestSuite();

        suite.AddAll(_category);

        TestResult res = suite.Run(null);

        Unity3D_TestReporter reporter = new Unity3D_TestReporter();

        reporter.LogResults(res, _prefix);
    }
示例#4
0
    /**
     * Initialize class resources.
     */
    public static void UnitTest()
    {
        // Create test suite
        TestSuite suite = new TestSuite();

        // Example: Add tests to suite
        suite.AddAll(new EMScheduler_Test());

        // Run the tests
        TestResult res = suite.Run(null);

        // Report results
        Unity3D_TestReporter reporter = new Unity3D_TestReporter();

        reporter.LogResults(res);
    }
    /**
     * Initialize class resources.
     */
    void Start()
    {
        // Create test suite
        TestSuite suite = new TestSuite();

        // Example: Add tests to suite
        suite.AddAll(new Dummy_Test());

        // Run the tests
        TestResult res = suite.Run(null);

        // Report results
        Unity3D_TestReporter reporter = new Unity3D_TestReporter();

        reporter.LogResults(res);
    }
示例#6
0
    public static void RunAllTests()
    {
        // Create test suite
        TestSuite suite = new TestSuite();

        // For each assembly in this app domain
        foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies())
        {
            // For each type in the assembly
            foreach (Type type in assem.GetTypes())
            {
                // If this is a valid test case
                // i.e. derived from TestCase and instantiable
                if (typeof(TestCase).IsAssignableFrom(type) &&
                    type != typeof(TestCase) &&
                    !type.IsAbstract)
                {
                    // Add tests to suite
                    suite.AddAll(type.GetConstructor(new Type[0]).Invoke(new object[0]) as TestCase);
                }
            }
        }

        // Run the tests
        TestResult res = suite.Run(null);


        var xmlReporter = new XML_TestReporter();

        if (!System.IO.Directory.Exists("TestReports"))
        {
            System.IO.Directory.CreateDirectory("TestReports");
        }
        xmlReporter.Init("TestReports/test-all.xml");
        xmlReporter.LogResults(res);
        if (res.NumFailed > 0)
        {
            EditorApplication.Exit(10);
        }
    }
示例#7
0
 public void TestAddAll_Null()
 {
     Assert.ExpectException(new Exception("Invalid test case encountered."));
     m_suite.AddAll(null);
 }