Example #1
0
 public bool IsReadySetupFilter(string check, TestFilter filter)
 {
     var reader = new StringReader(check);
     while (reader.Peek () != -1) {
         var line = reader.ReadLine ();
         if(line.StartsWith("++READY++")){
             return true;
         }else if(line.StartsWith("++INCLUDE++")){
             filter.Includes.Add (line.Replace ("++INCLUDE++", String.Empty));
         }else if(line.StartsWith("++EXCLUDE++")){
             filter.Excludes.Add (line.Replace ("++EXCLUDE++", String.Empty));
         }
     }
     return false;
 }
Example #2
0
        private TestRunState Run( ITestListener testListener, Runner runner, TestFilter filter)
        {
            var state = TestRunState.NoTests;

                     runner.RunAll(result =>{

                            testListener.TestFinished( new TestResult()
                                                                    {
                                                                        Name = String.Format("{0}.{1}",result.Test.Fixture.Name, result.Test.Name),
                                                                        FixtureType = ((Fixture)result.Test.Fixture).Type,
                                                                        StackTrace = result.Output,
                                                                        Method = ((Test)result.Test).Method,
                                                                        State = StateForResult(result.Kind),
                                                                        TimeSpan = result.EndTime - result.StartTime,
                                                                    });

                                    if(state == TestRunState.NoTests){
                                        switch (result.Kind)
                                        {
                                            case ResultKind.Fail:
                                                state = TestRunState.Failure;
                                                break;
                                            case ResultKind.Error:
                                                state = TestRunState.Error;
                                                break;
                                            default:
                                                state = TestRunState.Success;
                                                break;
                                        }
                                    } else if(state == TestRunState.Success || state == TestRunState.Failure){
                                        switch (result.Kind)
                                        {
                                            case ResultKind.Fail:
                                                state = TestRunState.Failure;
                                                break;
                                            case ResultKind.Error:
                                                state = TestRunState.Error;
                                                break;
                                        }
                                    }

                     }, filter);
            return state;
        }
Example #3
0
        public TestRunState RunMember(ITestListener testListener, Assembly assembly, MemberInfo member)
        {
            var type = member as Type;
            var method = member as MethodInfo;
            var testFilter = new TestFilter();

            var runner =Runner.Create("td-net", new[] {assembly});

            if (type != null)
            {

                foreach (var fixture in runner.Assemblies.SelectMany(a => a.Fixtures).OfType<Fixture>())
                {
                    if (fixture.Type == type)
                    {
                        testFilter.Includes.Add(fixture.UniqueName);
                    }
                }
            }else if (method != null)
            {

                foreach (var test in runner.Assemblies.SelectMany(a => a.Fixtures).SelectMany(f=>f.Tests).OfType<Test>())
                {
                    if (test.Method == method)
                    {
                        testFilter.Includes.Add(test.UniqueName);
                    }
                }

            }
            else
            {
                return TestRunState.NoTests;
            }

            return Run(testListener, runner, testFilter);
        }
Example #4
0
        public void RunAll(Action<Result> resultCallBack, TestFilter testFilter = null)
        {
            testFilter = testFilter ?? new TestFilter();

            foreach (var test in Tests)
            {
                if (!testFilter.ShouldRun(test))
                {
                    test.ParameterSetRelease();
                    continue;
                }
                var result = test.Run(Platform);
                resultCallBack(result);
            }
        }
Example #5
0
        public void Run(string id, string url, string[] dlls)
        {
            #if x64
            if(!Environment.Is64BitProcess)
                throw new Exception("This runner is expected to run 64bit");
            #endif

            Console.WriteLine("id:" + id);
            Console.WriteLine("server:" + url);
            Console.WriteLine("tests dlls:");
            foreach (var dll in dlls)
            {
                Console.WriteLine(dll);
            }
            Console.WriteLine("==========================");

            Console.Write("Connecting..");
            var connect = GetHttp (url, @"/api/connect/" + id);
            Console.WriteLine(connect);
            Console.WriteLine("Loading dlls..");

            #if SILVERLIGHT
            var am = dlls.Select(Assembly.Load).ToList();
            #else
            var am = dlls.Select(Assembly.LoadFile).ToList();
            #endif

            Console.WriteLine("Generating Tests...");

            var runner = Runner.Create(id, am);

            TestFilter receivedFilter = new TestFilter();

            Console.WriteLine("Sending Tests...");

            PostHttp (url, @"/api/send_tests", runner.ToListJson ());

            while (true) {
                var check = GetHttp (url, @"/api/check_tests");
                var run = IsReadySetupFilter(check, receivedFilter);
                if (!run)
                    Thread.Sleep (1000);
                else
                    break;
            }

            Console.WriteLine("Running Tests...");

            runner.RunAll(result => {
                PostHttp(url, @"/api/send_result", result.ToItemJson());
                          }, receivedFilter);

            Console.WriteLine("Quiting...");
        }