コード例 #1
0
ファイル: ctestcase.cs プロジェクト: wuyou201400/corefx
        public override tagVARIATION_STATUS Execute()
        {
            List <object> children = Children;

            if (children != null && children.Count > 0)
            {
                // this is not a leaf node, just invoke all the children's execute
                foreach (object child in children)
                {
                    CTestCase childTc = child as CTestCase;
                    if (childTc != null)    //nested test test case class will be child of a test case
                    {
                        childTc.Init();
                        childTc.Execute();
                        continue;
                    }
                    CVariation var = child as CVariation;
                    if (var != null && CModInfo.IsVariationSelected(var.Desc))
                    {
                        const string indent = "\t";
                        try
                        {
                            CurVariation = var;
                            tagVARIATION_STATUS ret = var.Execute();
                            if (tagVARIATION_STATUS.eVariationStatusPassed == ret)
                            {
                                TestModule.PassCount++;
                            }
                            else if (tagVARIATION_STATUS.eVariationStatusFailed == ret)
                            {
                                System.Console.WriteLine(indent + var.Desc);
                                System.Console.WriteLine(indent + " FAILED");
                                TestModule.FailCount++;
                            }
                            else
                            {
                                System.Console.WriteLine(indent + var.Desc);
                                System.Console.WriteLine(indent + " SKIPPED");
                                TestModule.SkipCount++;
                            }
                        }
                        catch (CTestSkippedException tse)
                        {
                            System.Console.WriteLine(indent + var.Desc);
                            System.Console.WriteLine(indent + " SKIPPED" + ", Msg:" + tse.Message);
                            TestModule.SkipCount++;
                        }
                        catch (Exception e)
                        {
                            System.Console.WriteLine(indent + var.Desc);
                            System.Console.WriteLine("unexpected exception happend:{0}", e.Message);
                            System.Console.WriteLine(e.StackTrace);
                            System.Console.WriteLine(indent + " FAILED");
                            TestModule.FailCount++;
                        }
                    }
                }
            }
            return(tagVARIATION_STATUS.eVariationStatusPassed);
        }
コード例 #2
0
ファイル: ctestbase.cs プロジェクト: wuyou201400/corefx
        public bool Terminate()
        {
            bool bResult = false;

            //NOTE: Since exceptions are a way-of-life in COOL, and the fact that they are just
            //caught by the runtime before passed back to LTM, we lose the entire stack and just
            //an unknown error code is returned.

            //To help solve this we will wrap the call in a try catch and actually
            //log the exception to the LTM output window...
            try
            {
                //Skipped
                if (this.Skipped || !this.Implemented)
                {
                    return(true);
                }

                if (Terminate(Param) == TEST_PASS)
                {
                    bResult = true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                HandleException(e);
            }

            try
            {
                //Clear any previous existing info (in the static class).
                if (this is CTestModule)
                {
                    //Note: We actually have to clear these "statics" since they are not cleaned up
                    //until the process exits.  Which means that if you run again, in an apartment model
                    //thread it will try to release these when setting them which is not allowed to
                    //call a method on an object created in another apartment
                    CModInfo.Dispose();
                }
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            //This is also a good point to hint to the GC to free up any unused memory
            //at the end of each TestCase and the end of each module.
            GC.Collect();
            GC.WaitForPendingFinalizers();
            return(bResult);
        }
コード例 #3
0
        public bool Terminate()
        {
            bool bResult = false;

            try
            {
                //Skipped
                if (this.Skipped || !this.Implemented)
                {
                    return(true);
                }

                if (Terminate(Param) == TEST_PASS)
                {
                    bResult = true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                HandleException(e);
            }

            try
            {
                //Clear any previous existing info (in the static class).
                if (this is CTestModule)
                {
                    //Note: We actually have to clear these "statics" since they are not cleaned up
                    //until the process exits.  Which means that if you run again, in an apartment model
                    //thread it will try to release these when setting them which is not allowed to
                    //call a method on an object created in another apartment
                    CModInfo.Dispose();
                }
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            //This is also a good point to hint to the GC to free up any unused memory
            //at the end of each TestCase and the end of each module.
            GC.Collect();
            GC.WaitForPendingFinalizers();
            return(bResult);
        }
コード例 #4
0
ファイル: ctestcase.cs プロジェクト: rsumner31/corefx2
        public void RunVariation(dlgtTestVariation testmethod, Variation curVar)
        {
            if (!CModInfo.IsVariationSelected(curVar.Desc))
            {
                return;
            }
            const string indent = "\t";

            try
            {
                CurVariation.Attribute = curVar;

                int ret = testmethod();
                if (TEST_PASS == ret)
                {
                    TestModule.PassCount++;
                }
                else if (TEST_FAIL == ret)
                {
                    System.Console.WriteLine(indent + curVar.Desc);
                    System.Console.WriteLine(indent + " FAILED");
                    TestModule.FailCount++;
                }
                else
                {
                    System.Console.WriteLine(indent + curVar.Desc);
                    System.Console.WriteLine(indent + " SKIPPED");
                    TestModule.SkipCount++;
                }
            }
            catch (CTestSkippedException tse)
            {
                System.Console.WriteLine(indent + curVar.Desc);
                System.Console.WriteLine(indent + " SKIPPED" + ", Msg:" + tse.Message);
                TestModule.SkipCount++;
            }
            catch (Exception e)
            {
                System.Console.WriteLine(indent + curVar.Desc);
                System.Console.WriteLine("unexpected exception happened:{0}", e.Message);
                System.Console.WriteLine(e.StackTrace);
                System.Console.WriteLine(indent + " FAILED");
                TestModule.FailCount++;
            }
        }
コード例 #5
0
ファイル: ctestcase.cs プロジェクト: rsumner31/corefx2
        public override IEnumerable <XunitTestCase> TestCases()
        {
            List <object> children = Children;

            if (children != null && children.Count > 0)
            {
                foreach (object child in children)
                {
                    CTestCase childTc = child as CTestCase;
                    if (childTc != null)
                    {
                        childTc.Init();

                        foreach (XunitTestCase testCase in childTc.TestCases())
                        {
                            yield return(testCase);
                        }

                        continue;
                    }

                    CVariation var = child as CVariation;
                    if (var != null && CModInfo.IsVariationSelected(var.Desc))
                    {
                        foreach (var testCase in var.TestCases())
                        {
                            Func <tagVARIATION_STATUS> test = testCase.Test;
                            testCase.Test = () => {
                                CurVariation = var;
                                return(test());
                            };

                            yield return(testCase);
                        }
                    }
                }
            }
        }
コード例 #6
0
ファイル: ctestmodule.cs プロジェクト: layomia/dotnet_runtime
        public override IEnumerable <XunitTestCase> TestCases()
        {
            List <object> children = Children;

            if (children != null && children.Count > 0)
            {
                foreach (object child in children)
                {
                    CTestCase tc = child as CTestCase;
                    if (tc != null)
                    {
                        if (CModInfo.IsTestCaseSelected(tc.Name))
                        {
                            tc.Init();
                            foreach (XunitTestCase testCase in tc.TestCases())
                            {
                                yield return(testCase);
                            }
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: ctestmodule.cs プロジェクト: layomia/dotnet_runtime
        public override tagVARIATION_STATUS Execute()
        {
            List <object> children = Children;

            if (children != null && children.Count > 0)
            {
                // this is not a leaf node, just invoke all the children's execute
                foreach (object child in children)
                {
                    CTestCase tc = child as CTestCase;
                    if (tc != null)
                    {
                        if (CModInfo.IsTestCaseSelected(tc.Name))
                        {
                            Console.WriteLine("TestCase:{0} - {1}", tc.Attribute.Name, tc.Attribute.Desc);
                            tc.Init();
                            tc.Execute();
                        }
                    }
                }
            }
            Console.WriteLine("Pass:{0}, Fail:{1}, Skip:{2}", PassCount, FailCount, SkipCount);
            return(tagVARIATION_STATUS.eVariationStatusPassed);
        }