NunitTestInfo NamespaceWithDot() { NunitTestInfo namespaceInfo = new NunitTestInfo { FixtureTypeName = "", FixtureTypeNamespace = "", Name = "A" }; NunitTestInfo namespaceInfo2 = new NunitTestInfo { FixtureTypeName = "", FixtureTypeNamespace = "", Name = "B" }; namespaceInfo.Tests [0] = namespaceInfo2; NunitTestInfo classInfo = new NunitTestInfo { FixtureTypeName = "TestClassAB", FixtureTypeNamespace = "A.B", Name = "TestClassAB" }; namespaceInfo2.Tests [0] = classInfo; NunitTestInfo methodInfo = new NunitTestInfo { FixtureTypeName = "TestClassAB", FixtureTypeNamespace = "A.B", Name = "TestMethodAB" }; classInfo.Tests [0] = methodInfo; return(namespaceInfo); }
NunitTestInfo NamespaceNoDot() { NunitTestInfo namespaceInfo = new NunitTestInfo { FixtureTypeName = "", FixtureTypeNamespace = "", Name = "A" }; NunitTestInfo classInfo = new NunitTestInfo { FixtureTypeName = "TestClassA", FixtureTypeNamespace = "A", Name = "TestClassA" }; namespaceInfo.Tests [0] = classInfo; NunitTestInfo methodInfo = new NunitTestInfo { FixtureTypeName = "TestClassA", FixtureTypeNamespace = "A", Name = "TestMethodA" }; classInfo.Tests [0] = methodInfo; return(namespaceInfo); }
public NUnitTestSuite(NUnitAssemblyTestSuite rootSuite, NunitTestInfo tinfo) : base(tinfo.Name) { fullName = !string.IsNullOrEmpty(tinfo.PathName) ? tinfo.PathName + "." + tinfo.Name : tinfo.Name; this.testInfo = tinfo; this.rootSuite = rootSuite; this.TestId = tinfo.TestId; }
public NUnitTestCase(NUnitAssemblyTestSuite rootSuite, NunitTestInfo tinfo, string className) : base(tinfo.Name) { this.className = className; this.pathName = tinfo.PathName; this.rootSuite = rootSuite; this.TestId = tinfo.TestId; }
public NUnitTestSuite (NUnitAssemblyTestSuite rootSuite, NunitTestInfo tinfo): base (tinfo.Name) { fullName = !string.IsNullOrEmpty (tinfo.PathName) ? tinfo.PathName + "." + tinfo.Name : tinfo.Name; this.testInfo = tinfo; this.rootSuite = rootSuite; this.TestId = tinfo.TestId; }
internal NunitTestInfo BuildTestInfo(Test test) { NunitTestInfo ti = new NunitTestInfo(); // The name of inherited tests include the base class name as prefix. // That prefix has to be removed string tname = test.TestName.Name; // Find the last index of the dot character that is not a part of the test parameters // Parameterized methods can contain '.' as class name & they don't seem to prefix base class name, so it's safe to skip them if (!(test.Parent is ParameterizedMethodSuite)) { int j = tname.IndexOf('('); int i = tname.LastIndexOf('.', (j == -1) ? (tname.Length - 1) : j); if (i != -1) { tname = tname.Substring(i + 1); } } if (test.FixtureType != null) { ti.FixtureTypeName = test.FixtureType.Name; ti.FixtureTypeNamespace = test.FixtureType.Namespace; } else if (test.TestType == "ParameterizedTest") { ti.FixtureTypeName = test.Parent.FixtureType.Name; ti.FixtureTypeNamespace = test.Parent.FixtureType.Namespace; } ti.Name = tname; ti.TestId = test.TestName.FullName; // Trim short name from end of full name to get the path string testNameWithDelimiter = "." + tname; if (test.TestName.FullName.EndsWith(testNameWithDelimiter)) { int pathLength = test.TestName.FullName.Length - testNameWithDelimiter.Length; ti.PathName = test.TestName.FullName.Substring(0, pathLength); } else { ti.PathName = null; } if (test.Tests != null && test.Tests.Count > 0) { ti.Tests = new NunitTestInfo [test.Tests.Count]; for (int n = 0; n < test.Tests.Count; n++) { ti.Tests [n] = BuildTestInfo((Test)test.Tests [n]); } } ti.IsExplicit = test.RunState == RunState.Explicit; return(ti); }
public void SetInfo(string path, NunitTestInfo info) { if (File.Exists(path)) { CachedTestInfo cti = new CachedTestInfo(); cti.LastWriteTime = File.GetLastWriteTime(path); cti.Info = info; table [path] = cti; modified = true; } }
internal NunitTestInfo BuildTestInfo(XmlElement test) { NunitTestInfo ti = new NunitTestInfo(); // The name of inherited tests include the base class name as prefix. // That prefix has to be removed string tname = test.GetAttribute("name"); string fullName = test.GetAttribute("fullname"); var tn = test.GetAttribute("classname"); if (tn != null) { var i = tn.LastIndexOf('.'); if (i != -1) { ti.FixtureTypeName = tn.Substring(i + 1); ti.FixtureTypeNamespace = tn.Substring(0, i); } else { ti.FixtureTypeName = tn; ti.FixtureTypeNamespace = ""; } } ti.Name = tname; ti.TestId = fullName; // Trim short name from end of full name to get the path string testNameWithDelimiter = "." + tname; if (fullName.EndsWith(testNameWithDelimiter)) { int pathLength = fullName.Length - testNameWithDelimiter.Length; ti.PathName = fullName.Substring(0, pathLength); } else { ti.PathName = null; } ti.IsExplicit = test.GetAttribute("classname") == "Explicit"; var children = test.ChildNodes.OfType <XmlElement> ().Where(e => e.LocalName == "test-suite" || e.LocalName == "test-case").ToArray(); if (children.Length > 0) { ti.Tests = new NunitTestInfo [children.Length]; for (int n = 0; n < children.Length; n++) { ti.Tests [n] = BuildTestInfo(children [n]); } } return(ti); }
protected override void OnCreateTests() { lock (locker) { if (Status == TestStatus.Loading) { return; } NunitTestInfo ti = testInfoCache.GetInfo(AssemblyPath); if (ti != null) { FillTests(ti); return; } Status = TestStatus.Loading; } lastAssemblyTime = GetAssemblyTime(); if (oldList != null) { foreach (UnitTest t in oldList) { Tests.Add(t); } } OnTestStatusChanged(); LoadData ld = new LoadData(); ld.Path = AssemblyPath; ld.TestInfoCachePath = cacheLoaded ? null : TestInfoCachePath; ld.Callback = delegate { DispatchService.GuiDispatch(delegate { AsyncCreateTests(ld); }); }; ld.SupportAssemblies = new List <string> (SupportAssemblies); AsyncLoadTest(ld); // Read the cache from disk only once cacheLoaded = true; }
NunitTestInfo DirectClassCase() { NunitTestInfo classInfo = new NunitTestInfo { FixtureTypeName = "TestClass", FixtureTypeNamespace = "", Name = "TestClass" }; NunitTestInfo methodInfo = new NunitTestInfo { FixtureTypeName = "TestClass", FixtureTypeNamespace = "", Name = "TestMethod" }; classInfo.Tests [0] = methodInfo; return(classInfo); }
void FillTests(NunitTestInfo ti) { if (ti.Tests == null) { return; } foreach (NunitTestInfo test in ti.Tests) { if (test.Tests != null) { Tests.Add(new NUnitTestSuite(this, test)); } else { Tests.Add(new NUnitTestCase(this, test)); } } oldList = new UnitTest [Tests.Count]; Tests.CopyTo(oldList, 0); }
NunitTestInfo NestedNamespace() { NunitTestInfo namespaceInfo = new NunitTestInfo { FixtureTypeName = "", FixtureTypeNamespace = "", Name = "A" }; NunitTestInfo namespaceInfo2 = new NunitTestInfo { FixtureTypeName = "", FixtureTypeNamespace = "", Name = "B" }; namespaceInfo.Tests [0] = namespaceInfo2; NunitTestInfo namespaceInfo3 = new NunitTestInfo { FixtureTypeName = "", FixtureTypeNamespace = "", Name = "C" }; namespaceInfo2.Tests [0] = namespaceInfo3; NunitTestInfo classInfo = new NunitTestInfo { FixtureTypeName = "TestClassABC", FixtureTypeNamespace = "A.B.C", Name = "TestClassABC" }; namespaceInfo3.Tests [0] = classInfo; NunitTestInfo methodInfo = new NunitTestInfo { FixtureTypeName = "TestClassABC", FixtureTypeNamespace = "A.B.C", Name = "TestMethodABC" }; classInfo.Tests [0] = methodInfo; return(namespaceInfo); }
void FillTests(NunitTestInfo ti) { if (ti.Tests == null) { return; } foreach (NunitTestInfo test in ti.Tests) { UnitTest newTest; if (test.Tests != null) { newTest = new NUnitTestSuite(this, test); } else { newTest = new NUnitTestCase(this, test, test.PathName); } newTest.FixtureTypeName = test.FixtureTypeName; newTest.FixtureTypeNamespace = test.FixtureTypeNamespace; Tests.Add(newTest); } oldList = new UnitTest [Tests.Count]; Tests.CopyTo(oldList, 0); }
public NUnitTestCase(NUnitAssemblyTestSuite rootSuite, NunitTestInfo tinfo) : base(tinfo.Name) { className = tinfo.PathName; this.rootSuite = rootSuite; }
public void SetInfo (string path, NunitTestInfo info) { if (File.Exists (path)) { CachedTestInfo cti = new CachedTestInfo (); cti.LastWriteTime = File.GetLastWriteTime (path); cti.Info = info; table [path] = cti; modified = true; } }
static void RunAsyncLoadTest() { while (true) { LoadData ld; lock (loadQueue) { if (loadQueue.Count == 0) { if (!Monitor.Wait(loadQueue, 5000, true)) { loaderRunning = false; return; } } ld = (LoadData)loadQueue.Dequeue(); } try { // If the information is cached in a file and it is up to date information, // there is no need to parse again the assembly. if (ld.TestInfoCachePath != null && File.Exists(ld.TestInfoCachePath)) { ld.InfoCache = TestInfoCache.Read(ld.TestInfoCachePath); NunitTestInfo info = ld.InfoCache.GetInfo(ld.Path); if (info != null) { ld.Info = info; ld.Callback(ld); continue; } } } catch (Exception ex) { LoggingService.LogError(ex.ToString()); } ExternalTestRunner runner = null; try { if (File.Exists(ld.Path)) { runner = (ExternalTestRunner)Runtime.ProcessService.CreateExternalProcessObject(typeof(ExternalTestRunner), false); ld.Info = runner.GetTestInfo(ld.Path, ld.SupportAssemblies); } } catch (Exception ex) { Console.WriteLine(ex); ld.Error = ex; } finally { try { if (runner != null) { runner.Dispose(); } } catch {} } try { ld.Callback(ld); } catch { } } }
internal NunitTestInfo BuildTestInfo (Test test) { NunitTestInfo ti = new NunitTestInfo (); // The name of inherited tests include the base class name as prefix. // That prefix has to be removed string tname = test.TestName.Name; // Find the last index of the dot character that is not a part of the test parameters // Parameterized methods can contain '.' as class name & they don't seem to prefix base class name, so it's safe to skip them if (!(test.Parent is ParameterizedMethodSuite)) { int j = tname.IndexOf ('('); int i = tname.LastIndexOf ('.', (j == -1) ? (tname.Length - 1) : j); if (i != -1) tname = tname.Substring (i + 1); } if (test.FixtureType != null) { ti.FixtureTypeName = test.FixtureType.Name; ti.FixtureTypeNamespace = test.FixtureType.Namespace; } else if (test.TestType == "ParameterizedTest") { ti.FixtureTypeName = test.Parent.FixtureType.Name; ti.FixtureTypeNamespace = test.Parent.FixtureType.Namespace; } ti.Name = tname; ti.TestId = test.TestName.FullName; // Trim short name from end of full name to get the path string testNameWithDelimiter = "." + tname; if (test.TestName.FullName.EndsWith (testNameWithDelimiter)) { int pathLength = test.TestName.FullName.Length - testNameWithDelimiter.Length; ti.PathName = test.TestName.FullName.Substring(0, pathLength ); } else ti.PathName = null; if (test.Tests != null && test.Tests.Count > 0) { ti.Tests = new NunitTestInfo [test.Tests.Count]; for (int n=0; n<test.Tests.Count; n++) ti.Tests [n] = BuildTestInfo ((Test)test.Tests [n]); } ti.IsExplicit = test.RunState == RunState.Explicit; return ti; }
internal NunitTestInfo BuildTestInfo (XmlElement test) { NunitTestInfo ti = new NunitTestInfo (); // The name of inherited tests include the base class name as prefix. // That prefix has to be removed string tname = test.GetAttribute ("name"); string fullName = test.GetAttribute ("fullname"); var tn = test.GetAttribute ("classname"); if (tn != null) { var i = tn.LastIndexOf ('.'); if (i != -1) { ti.FixtureTypeName = tn.Substring (i + 1); ti.FixtureTypeNamespace = tn.Substring (0, i); } else { ti.FixtureTypeName = tn; ti.FixtureTypeNamespace = ""; } } ti.Name = tname; ti.TestId = fullName; // Trim short name from end of full name to get the path string testNameWithDelimiter = "." + tname; if (fullName.EndsWith (testNameWithDelimiter)) { int pathLength = fullName.Length - testNameWithDelimiter.Length; ti.PathName = fullName.Substring (0, pathLength); } else ti.PathName = null; ti.IsExplicit = test.GetAttribute ("classname") == "Explicit"; var children = test.ChildNodes.OfType<XmlElement> ().Where (e => e.LocalName == "test-suite" || e.LocalName == "test-case").ToArray (); if (children.Length > 0) { ti.Tests = new NunitTestInfo [children.Length]; for (int n=0; n<children.Length; n++) ti.Tests [n] = BuildTestInfo (children [n]); } return ti; }
public NUnitTestSuite(NUnitAssemblyTestSuite rootSuite, NunitTestInfo tinfo) : base(tinfo.Name) { fullName = tinfo.PathName != null && tinfo.PathName.Length > 0 ? tinfo.PathName + "." + tinfo.Name : tinfo.Name; this.testInfo = tinfo; this.rootSuite = rootSuite; }
void FillTests (NunitTestInfo ti) { if (ti.Tests == null) return; foreach (NunitTestInfo test in ti.Tests) { UnitTest newTest; if (test.Tests != null) newTest = new NUnitTestSuite (this, test); else newTest = new NUnitTestCase (this, test, test.PathName); newTest.FixtureTypeName = test.FixtureTypeName; newTest.FixtureTypeNamespace = test.FixtureTypeNamespace; Tests.Add (newTest); } oldList = new UnitTest [Tests.Count]; Tests.CopyTo (oldList, 0); }