public override void TestsStarting(object sender, TestEventArgs <UnitTestMethod> args) { ConsoleMethod test = args.Test; TestSuiteDefinition suite = GetTestSuiteDefinition(test); SetTestSuiteExecutionSummary(suite); }
public TestResult(ConsoleMethod cim, TestType testType = Testing.TestType.Unit) : this() { MethodInfo method = cim.Method; MethodName = method.Name; Description = cim.Information; AssemblyFullName = method.DeclaringType.Assembly.FullName; Passed = true; TestType = testType.ToString(); }
private static void TryInvoke <T>(ConsoleMethod cim) { try { cim.Invoke(); } catch (Exception ex) { OutLineFormat("Exception in {0} method {1}: {2}", ConsoleColor.Magenta, typeof(T).Name, cim.Method.Name, ex.Message); } }
public static void AddKeyword(string name, ConsoleMethod method = null, int minimumParameters = -1, string help = "") { if (!Proxy.IsPlaying()) { return; } ConsoleCallback call = new ConsoleCallback(); call.basic = method; call.help = help; call.minimumParameters = minimumParameters; Console.AddKeyword(name, call); }
private static string GetSuiteTitle(ConsoleMethod test) { if (test == null || test.Method == null) { throw new ArgumentNullException("test"); } string title = GetSuiteTitle(test.Method.DeclaringType); if (test.Method.HasCustomAttributeOfType(out TestSuiteAttribute methodAttr)) { title = methodAttr.Title; } return(title); }
private static string GetSuiteTitle(ConsoleMethod test) { Args.ThrowIfNull(test); Args.ThrowIfNull(test.Method); Type containingType = test.Method.DeclaringType; string title = $"{containingType.Assembly.FullName}:{containingType.Name}"; if (containingType.HasCustomAttributeOfType(out TestSuiteAttribute typeAttr)) { title = typeAttr.Title; } else if (test.Method.HasCustomAttributeOfType(out TestSuiteAttribute methodAttr)) { title = methodAttr.Title; } return(title); }
/// <summary> /// Get a TestSuiteDefinition for the specified test creating it if necessary /// and populating the internal cache /// </summary> /// <param name="test"></param> /// <returns></returns> protected TestSuiteDefinition GetTestSuiteDefinition(ConsoleMethod test) { TestSuiteDefinition suite = TestSuiteDefinition.FromMethod(test); if (!_testSuiteDefinitionLookupByTitle.TryGetValue(suite.Title, out suite)) { GetSuiteDefinitionResponse response = TestReportService.GetSuiteDefinition(suite.Title); if (response.Success) { _testSuiteDefinitionLookupByTitle.TryAdd(suite.Title, response.SuiteDefinition); } else { Logger.Warning("Failed to define test suite: {0}", response.Message); } } return(suite); }
protected internal static void InvokeTest(ConsoleMethod consoleMethod, Func <MethodInfo, object[]> parameterProvider, bool isolateMethodCalls = true) { object[] parameters = parameterProvider(consoleMethod.Method); MethodInfo invokeTarget = typeof(ConsoleMethod).GetMethod("Invoke"); if (consoleMethod.Method.IsStatic) { if (isolateMethodCalls) { CommandLineInterface.InvokeInSeparateAppDomain(invokeTarget, consoleMethod); } else { CommandLineInterface.InvokeInCurrentAppDomain(invokeTarget, consoleMethod); } } else { string typeName = consoleMethod.Method.DeclaringType.Name; ConstructorInfo ctor = consoleMethod.Method.DeclaringType.GetConstructor(Type.EmptyTypes); if (ctor == null) { ExceptionHelper.ThrowInvalidOperation("The declaring type {0} of method {1} does not have a parameterless constructor, test cannot be run.", typeName, consoleMethod.Method.Name); } object instance = ctor.Invoke(null); Expect.IsNotNull(instance, string.Format("Unable to instantiate declaring type {0} of method {1}", typeName, consoleMethod.Method.Name)); consoleMethod.Provider = instance; if (isolateMethodCalls) { CommandLineInterface.InvokeInSeparateAppDomain(invokeTarget, consoleMethod); } else { CommandLineInterface.InvokeInCurrentAppDomain(invokeTarget, consoleMethod); } } }
/// <summary> /// Get a TestSuiteDefinition for the specified test creating it if necessary /// and populating the internal cache /// </summary> /// <param name="args"></param> /// <returns></returns> protected TestSuiteDefinition GetTestSuiteDefinition <TTestMethod>(TestEventArgs <TTestMethod> args) where TTestMethod : TestMethod { ConsoleMethod test = args.Test; TestSuiteDefinition suite = TestSuiteDefinition.FromTestEventArgs(args); if (!_testSuiteDefinitionLookupByTitle.TryGetValue(suite.Title, out TestSuiteDefinition fromCache)) { GetSuiteDefinitionResponse response = TestReportService.GetSuiteDefinition(suite.Title); if (response.Success) { _testSuiteDefinitionLookupByTitle.TryAdd(suite.Title, response.SuiteDefinition); } else { Logger.Warning("Failed to define test suite: {0}", response.Message); } } if (fromCache != null) { suite = fromCache; } return(suite); }
public Vector3Command (ConsoleMethod method):base(method){}
public static TestSuiteDefinition FromMethod(ConsoleMethod test) { return(new TestSuiteDefinition { Title = GetSuiteTitle(test) }); }
public List <ConsoleMethod> GetBeforeAllMethods(Assembly assembly) { return(ConsoleMethod.FromAssembly <BeforeUnitTests>(assembly)); }
public List <ConsoleMethod> GetBeforeEachMethods(Assembly assembly) { return(ConsoleMethod.FromAssembly <BeforeEachUnitTest>(assembly)); }
public ParamsCommand(ConsoleMethod method) : base(method) { }
public Vector3Command (ConsoleMethod method, string helpText):base(method, helpText){}
public Command(ConsoleMethod method) : base(method) { }
public Vector2Command (string name, ConsoleMethod method, string helpText):base(name, method, helpText){}
public CommandParams(string title, ConsoleMethod method) : base(title, method) { }
public Command(string title, ConsoleMethod method, string helpText) : base(title, method, helpText) { }
public Vector3Command(string name, ConsoleMethod method, HelpMethod helpMethod) : base(name, method, helpMethod) { }
public Vector3Command(string name, ConsoleMethod method, string helpText) : base(name, method, helpText) { }
public Vector3Command (ConsoleMethod method, HelpMethod helpMethod):base(method, helpMethod){}
public Vector3Command (string name, ConsoleMethod method, HelpMethod helpMethod):base(name, method, helpMethod){}
public Command(ConsoleMethod method, HelpMethod helpMethod) : base(method, helpMethod) { }
public Vector3Command(ConsoleMethod method) : base(method) { }
public Vector2Command (string name, ConsoleMethod method):base(name, method){}
public CommandParams(ConsoleMethod method) : base(method) { }
public Vector2Command(string name, ConsoleMethod method) : base(name, method) { }
public Command(string title, ConsoleMethod method, HelpMethod helpMethod) : base(title, method, helpMethod) { }
public ParamsCommand(string name, ConsoleMethod method, HelpMethod helpMethod) : base(name, method, helpMethod) { }
public Command(ConsoleMethod method, string helpText) : base(method, helpText) { }
public List <ConsoleMethod> GetAfterAllMethods(Assembly assembly) { return(ConsoleMethod.FromAssembly <AfterUnitTests>(assembly)); }
public ParamsCommand(string name, ConsoleMethod method, string helpText) : base(name, method, helpText) { }
public static void AddCvarMethod(string name, object scope, string dataName, string fullName = "", string help = "", ConsoleMethod method = null) { if (!Proxy.IsPlaying()) { return; } Console.AddCvar(name, scope, dataName, fullName, help); Console.cvars[name].method.basic = method; }