我正在使用Visual Studio 2017 Professional 15.4.5,我发现.testsettings通过在Test > Test Settings > Select Test Settings菜单中选择遗留加载旧版时将不会发现单元测试
以下是重现它的步骤:
使用以下简单类创建Class Library具有目标框架的项目.NET Framework 4.5.2:
public class Class1
{
public bool True => true;
}
Run Code Online (Sandbox Code Playgroud)创建一个Unit Test Project(.Net Framework)带有目标框架.NET Framework 4.5.2和设置项目参考并编写一个简单的测试:
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
Assert.IsTrue(new Class1().True);
}
}
Run Code Online (Sandbox Code Playgroud)运行测试,应该发现并运行测试
Add > New Item,Test Settings在左侧窗格中选择Test Settings并在中间选择以创建新的测试设置.Test > Test Settings > Select …我有一个引用这样的主题的WebForm:
<%@ Page Title="Test" Language="C#" MasterPageFile="~/Test.master" AutoEventWireup="true"
CodeFile="Test.aspx.cs" Inherits="Test" Theme="TestTheme"%>
Run Code Online (Sandbox Code Playgroud)
并且TestTheme只包含一个Test.skin文件,其中包含以下内容:
<asp:Button runat="server" CssClass="button" />
Run Code Online (Sandbox Code Playgroud)
如果我执行页面,我总是得到一个编译错误消息,如下所示:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: The compiler failed with error code -1073741701.
Run Code Online (Sandbox Code Playgroud)
仔细查看生成的html后,我发现了这条隐藏的消息:
<!--
[HttpCompileException]: External component has thrown an exception.
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(String themeName)
at System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(HttpContext context, String themeName)
at System.Web.UI.Page.InitializeThemes()
at …Run Code Online (Sandbox Code Playgroud)