public DiscoveryRecorder(IMessageLogger log, ITestCaseDiscoverySink discoverySink, string assemblyPath) { this.log = log; this.discoverySink = discoverySink; this.assemblyPath = assemblyPath; sourceLocationProvider = new SourceLocationProvider(assemblyPath); }
static void AssertNoLineNumber(string className, string methodName) { var sourceLocationProvider = new SourceLocationProvider(TestAssemblyPath); SourceLocation location; var success = sourceLocationProvider.TryGetSourceLocation(new MethodGroup(className + "." + methodName), out location); success.ShouldBeFalse(); location.ShouldBeNull(); }
public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger log, ITestCaseDiscoverySink discoverySink) { log.Version(); RemotingUtility.CleanUpRegisteredChannels(); foreach (var assemblyPath in sources) { try { if (AssemblyDirectoryContainsFixie(assemblyPath)) { log.Info("Processing " + assemblyPath); var sourceLocationProvider = new SourceLocationProvider(assemblyPath); using (var environment = new ExecutionEnvironment(assemblyPath)) { var methodGroups = environment.DiscoverTestMethodGroups(new Options()); foreach (var methodGroup in methodGroups) { var testCase = new TestCase(methodGroup.FullName, VsTestExecutor.Uri, assemblyPath); try { SourceLocation sourceLocation; if (sourceLocationProvider.TryGetSourceLocation(methodGroup, out sourceLocation)) { testCase.CodeFilePath = sourceLocation.CodeFilePath; testCase.LineNumber = sourceLocation.LineNumber; } } catch (Exception exception) { log.Error(exception); } discoverySink.SendTestCase(testCase); } } } else { log.Info("Skipping " + assemblyPath + " because it is not a test assembly."); } } catch (Exception exception) { log.Error(exception); } } }
public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger log, ITestCaseDiscoverySink discoverySink) { log.Version(); RemotingUtility.CleanUpRegisteredChannels(); foreach (var assemblyPath in sources) { try { if (AssemblyDirectoryContainsFixie(assemblyPath)) { log.Info("Processing " + assemblyPath); var sourceLocationProvider = new SourceLocationProvider(assemblyPath); using (var environment = new ExecutionEnvironment(assemblyPath)) { var methodGroups = environment.DiscoverTestMethodGroups(new Options()); foreach (var methodGroup in methodGroups) { var testCase = new TestCase(methodGroup.FullName, VsTestExecutor.Uri, assemblyPath); try { SourceLocation sourceLocation; if (sourceLocationProvider.TryGetSourceLocation(methodGroup, out sourceLocation)) { testCase.CodeFilePath = sourceLocation.CodeFilePath; testCase.LineNumber = sourceLocation.LineNumber; } } catch (Exception exception) { log.Error(exception); } discoverySink.SendTestCase(testCase); } } } else { log.Info("Skipping " + assemblyPath + " because it is not a test assembly."); } } catch (Exception exception) { log.Error(exception); } } }
static void AssertLineNumber(string className, string methodName, int debugLine, int releaseLine) { var sourceLocationProvider = new SourceLocationProvider(TestAssemblyPath); SourceLocation location; var success = sourceLocationProvider.TryGetSourceLocation(new MethodGroup(className + "." + methodName), out location); location.CodeFilePath.EndsWith("SourceLocationSamples.cs").ShouldBeTrue(); #if DEBUG location.LineNumber.ShouldEqual(debugLine); #else location.LineNumber.ShouldEqual(releaseLine); #endif }