protected internal override TestDirectory CreateField(ExtensionContext extensionContext) { ExtensionContext.Store fileSystemStore = GetStore(extensionContext, FileSystemExtension.FileSystemNamespace); FileSystemAbstraction fileSystemAbstraction = fileSystemStore.get(FileSystemExtension.FILE_SYSTEM, typeof(FileSystemAbstraction)); return(fileSystemAbstraction != null?testDirectory(fileSystemAbstraction) : testDirectory()); }
public override void AfterEach(ExtensionContext context) { Profiler profiler = GetStoredValue(context); try { profiler.Finish(); if (context.ExecutionException.Present) { ExtensionContext.Store testDirStore = GetStore(context, TestDirectoryExtension.TestDirectoryNamespace); TestDirectory testDir = ( TestDirectory )testDirStore.get(TestDirectoryExtension.TEST_DIRECTORY); File profileOutputFile = testDir.CreateFile("profiler-output.txt"); FileSystemAbstraction fs = testDir.FileSystem; using (PrintStream @out = new PrintStream(fs.OpenAsOutputStream(profileOutputFile, false))) { string displayName = context.TestClass.map(Type.getSimpleName).orElse("class") + "." + context.DisplayName; profiler.PrintProfile(@out, displayName); } } } catch (Exception e) { throw new JUnitException("Failed to finish profiling and/or produce profiling output.", e); } }