void LoadProject(string filename) { var splash = new LoaderForm(); try { splash.Show(); splash.Update(); UnloadAssemblies(listAssemblies.Items); listAssemblies.Update(); project = XunitProject.Load(filename); mruProjectList.Add(filename); foreach (XunitProjectAssembly assembly in project.Assemblies) { AddTestAssembly(mate.Load(assembly.AssemblyFilename, assembly.ConfigFilename, assembly.ShadowCopy)); } } catch (Exception ex) { MessageBox.Show("Error loading project:\r\n\r\n" + ex.Message, windowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { splash.Close(); splash.Dispose(); } UpdateAssemblyDynamicMenus(); UpdateProjectDynamicMenus(); }
public void LoadAcceptanceTest() { string xml = @"<xunit2>" + Environment.NewLine + @" <assembly filename='C:\AssemblyFilename' config-filename='C:\ConfigFilename' shadow-copy='false' />" + Environment.NewLine + @" <assembly filename='C:\AssemblyFilename2' config-filename='C:\ConfigFilename2' shadow-copy='true' />" + Environment.NewLine + @" <output type='xml' filename='C:\XmlFilename' />" + Environment.NewLine + @" <output type='xmlv1' filename='C:\Xmlv1Filename' />" + Environment.NewLine + @" <output type='html' filename='C:\HtmlFilename' />" + Environment.NewLine + @"</xunit2>"; XunitProject project; using (var tempFile = new TempFile(xml)) project = XunitProject.Load(tempFile.Filename); Assert.Collection(project.Assemblies, assembly => { Assert.Equal(@"C:\AssemblyFilename", assembly.AssemblyFilename); Assert.Equal(@"C:\ConfigFilename", assembly.ConfigFilename); Assert.False(assembly.ShadowCopy); }, assembly => { Assert.Equal(@"C:\AssemblyFilename2", assembly.AssemblyFilename); Assert.Equal(@"C:\ConfigFilename2", assembly.ConfigFilename); Assert.True(assembly.ShadowCopy); } ); Assert.Equal(@"C:\XmlFilename", project.Output["xml"]); Assert.Equal(@"C:\Xmlv1Filename", project.Output["xmlv1"]); Assert.Equal(@"C:\HtmlFilename", project.Output["html"]); }
public void FilenamesAreRelativeToTheProjectLocation() { string xml = @" <xunit> <assemblies> <assembly filename='AssemblyFilename' config-filename='ConfigFilename'> <output type='xml' filename='XmlFilename' /> </assembly> </assemblies> </xunit>"; XunitProject project; string directory; using (TempFile tempFile = new TempFile(xml)) { directory = Path.GetDirectoryName(tempFile.Filename); project = XunitProject.Load(tempFile.Filename); } XunitProjectAssembly assembly = Assert.Single(project.Assemblies); Assert.Equal(Path.Combine(directory, "AssemblyFilename"), assembly.AssemblyFilename); Assert.Equal(Path.Combine(directory, "ConfigFilename"), assembly.ConfigFilename); KeyValuePair <string, string> output = Assert.Single(assembly.Output); Assert.Equal(Path.Combine(directory, "XmlFilename"), output.Value); }
public void LoadAcceptanceTest() { string xml = @" <xunit> <assemblies> <assembly filename='C:\AssemblyFilename' config-filename='C:\ConfigFilename' shadow-copy='false'> <output type='xml' filename='C:\XmlFilename' /> <output type='nunit' filename='C:\NunitFilename' /> <output type='html' filename='C:\HtmlFilename' /> </assembly> <assembly filename='C:\AssemblyFilename2' config-filename='C:\ConfigFilename2' shadow-copy='true'> <output type='xml' filename='C:\XmlFilename2' /> <output type='nunit' filename='C:\NunitFilename2' /> <output type='html' filename='C:\HtmlFilename2' /> </assembly> </assemblies> </xunit>"; XunitProject project; using (TempFile tempFile = new TempFile(xml)) project = XunitProject.Load(tempFile.Filename); List <XunitProjectAssembly> assemblies = new List <XunitProjectAssembly>(project.Assemblies); Assert.Equal(2, assemblies.Count()); XunitProjectAssembly assembly1 = assemblies[0]; Assert.Equal(@"C:\AssemblyFilename", assembly1.AssemblyFilename); Assert.Equal(@"C:\ConfigFilename", assembly1.ConfigFilename); Assert.False(assembly1.ShadowCopy); Assert.Equal(3, assembly1.Output.Count); Assert.Equal(@"C:\XmlFilename", assembly1.Output["xml"]); Assert.Equal(@"C:\NunitFilename", assembly1.Output["nunit"]); Assert.Equal(@"C:\HtmlFilename", assembly1.Output["html"]); XunitProjectAssembly assembly2 = assemblies[1]; Assert.Equal(@"C:\AssemblyFilename2", assembly2.AssemblyFilename); Assert.Equal(@"C:\ConfigFilename2", assembly2.ConfigFilename); Assert.True(assembly2.ShadowCopy); Assert.Equal(3, assembly2.Output.Count); Assert.Equal(@"C:\XmlFilename2", assembly2.Output["xml"]); Assert.Equal(@"C:\NunitFilename2", assembly2.Output["nunit"]); Assert.Equal(@"C:\HtmlFilename2", assembly2.Output["html"]); }
public void AssemblyFilenameOnly() { string xml = @"<xunit2>" + Environment.NewLine + @" <assembly filename='C:\AssemblyFilename' />" + Environment.NewLine + @"</xunit2>"; using (TempFile tempFile = new TempFile(xml)) { var project = XunitProject.Load(tempFile.Filename); Assert.Equal(0, project.Output.Count); Assert.Equal(tempFile.Filename, project.Filename); var assembly = Assert.Single(project.Assemblies); Assert.Equal(@"C:\AssemblyFilename", assembly.AssemblyFilename); Assert.Null(assembly.ConfigFilename); Assert.True(assembly.ShadowCopy); } }
public void AssemblyFilenameOnly() { string xml = @" <xunit> <assemblies> <assembly filename='C:\AssemblyFilename' /> </assemblies> </xunit>"; using (TempFile tempFile = new TempFile(xml)) { XunitProject project = XunitProject.Load(tempFile.Filename); Assert.Equal(tempFile.Filename, project.Filename); XunitProjectAssembly assembly = Assert.Single(project.Assemblies); Assert.Equal(@"C:\AssemblyFilename", assembly.AssemblyFilename); Assert.Null(assembly.ConfigFilename); Assert.True(assembly.ShadowCopy); Assert.Equal(0, assembly.Output.Count); } }
public void FilenamesAreRelativeToTheProjectLocation() { string xml = @"<xunit2>" + Environment.NewLine + @" <assembly filename='AssemblyFilename' config-filename='ConfigFilename' />" + Environment.NewLine + @" <output type='xml' filename='XmlFilename' />" + Environment.NewLine + @"</xunit2>"; XunitProject project; string directory; using (var tempFile = new TempFile(xml)) { directory = Path.GetDirectoryName(tempFile.Filename); project = XunitProject.Load(tempFile.Filename); } var assembly = Assert.Single(project.Assemblies); Assert.Equal(Path.Combine(directory, "AssemblyFilename"), assembly.AssemblyFilename); Assert.Equal(Path.Combine(directory, "ConfigFilename"), assembly.ConfigFilename); var output = Assert.Single(project.Output); Assert.Equal(Path.Combine(directory, "XmlFilename"), output.Value); }
protected virtual XunitProject GetMultiAssemblyProject(string filename) { return(XunitProject.Load(filename)); }
public override bool Execute() { RemotingUtility.CleanUpRegisteredChannels(); try { ExitCode = 0; string projectFilename = ProjectFile.GetMetadata("FullPath"); XunitProject project = XunitProject.Load(projectFilename); IRunnerLogger logger = TeamCity ? (IRunnerLogger) new TeamCityLogger(Log) : Verbose ? new VerboseLogger(Log) : new StandardLogger(Log); Log.LogMessage(MessageImportance.High, "xUnit.net MSBuild runner ({0}-bit .NET {1})", IntPtr.Size * 8, Environment.Version); foreach (XunitProjectAssembly assembly in project.Assemblies) { using (Stream htmlStream = ResourceStream("HTML.xslt")) using (Stream nunitStream = ResourceStream("NUnitXml.xslt")) using (ExecutorWrapper wrapper = new ExecutorWrapper(assembly.AssemblyFilename, assembly.ConfigFilename, assembly.ShadowCopy)) { Log.LogMessage(MessageImportance.High, " Test assembly: {0}", assembly.AssemblyFilename); Log.LogMessage(MessageImportance.High, " xunit.dll version: {0}", wrapper.XunitVersion); List <IResultXmlTransform> transforms = new List <IResultXmlTransform>(); foreach (KeyValuePair <string, string> kvp in assembly.Output) { switch (kvp.Key.ToLowerInvariant()) { case "xml": transforms.Add(new NullTransformer(kvp.Value)); break; case "html": transforms.Add(new XslStreamTransformer(htmlStream, kvp.Value)); break; case "nunit": transforms.Add(new XslStreamTransformer(nunitStream, kvp.Value)); break; default: Log.LogWarning("Unknown output type: '{0}'", kvp.Key); break; } } TestRunner runner = new TestRunner(wrapper, logger); if (runner.RunAssembly(transforms) == TestRunnerResult.Failed) { ExitCode = -1; } } } StandardLogger stdLogger = logger as StandardLogger; if (stdLogger != null) { Log.LogMessage(MessageImportance.High, "TOTAL Tests: {0}, Failures: {1}, Skipped: {2}, Time: {3} seconds", stdLogger.Total, stdLogger.Failed, stdLogger.Skipped, stdLogger.Time.ToString("0.000")); } } catch (Exception ex) { Exception e = ex; while (e != null) { Log.LogError(e.GetType().FullName + ": " + e.Message); foreach (string stackLine in e.StackTrace.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)) { Log.LogError(stackLine); } e = e.InnerException; } ExitCode = -1; } return(ExitCode == 0); }
public void NullFilenameThrows() { Assert.Throws <ArgumentNullException>(() => XunitProject.Load(null)); }
public void InvalidXmlFormatThrows() { using (TempFile tempFile = new TempFile("<invalid />")) Assert.Throws <ArgumentException>(() => XunitProject.Load(tempFile.Filename)); }
public void InvalidFilenameThrows() { Assert.Throws <FileNotFoundException>( () => XunitProject.Load(Guid.NewGuid().ToString())); }