Esempio n. 1
0
        public ExecutionTests(ITestOutputHelper testOutputHelper)
        {
            _testOutputHelper = testOutputHelper;

            #if DEBUG
            var testName = ((ITest)
                            _testOutputHelper
                            .GetType()
                            .GetField("test", BindingFlags.Instance | BindingFlags.NonPublic) !
                            .GetValue(_testOutputHelper) !
                            ).DisplayName.Replace(GetType().FullName + ".", "");
            var safeTestName = Regex.Replace(testName, "[^a-zA-Z._-]+", "_");
            if (safeTestName.Length > 100)
            {
                safeTestName = safeTestName.Substring(0, 100) + "-" + safeTestName.GetHashCode();
            }

            var testPath = Path.Combine(
                AppContext.BaseDirectory, "assembly-log",
                GetType().Name, safeTestName,
                "{0}.dll"
                );
            AssemblyLog.Enable(testPath);
            #endif
        }
Esempio n. 2
0
        public static void Enable(ITestOutputHelper output)
        {
            var test = ((ITest)
                        output
                        .GetType()
                        .GetField("test", BindingFlags.Instance | BindingFlags.NonPublic) !
                        .GetValue(output) !
                        );
            var testType = test.TestCase.TestMethod.TestClass.Class.ToRuntimeType();
            var testName = test.DisplayName.Replace(testType.FullName + ".", "");

            var safeTestName = Regex.Replace(testName, "[^a-zA-Z._-]+", "_");

            if (safeTestName.Length > 100)
            {
                safeTestName = safeTestName.Substring(0, 100) + "-" + safeTestName.GetHashCode();
            }

            var testPath = Path.Combine(
                AppContext.BaseDirectory, "assembly-log",
                testType.Name, safeTestName,
                "{0}.dll"
                );

            #if DEBUG
            AssemblyLog.Enable(testPath);
            #endif
        }