Issue with Name format assignment in 3.12
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- csharp
- 领域
- documentation, testing
调研方向
从 SetName 和 TestCaseData 文档以及提供的 DemoTestClass 复现开始;将文档中说明的格式行为与在 NUnit 和所提及的测试运行器中观察到的测试名称进行比较。完成的标准是确定文档或行为是否不正确,并更新相关文档,以准确描述 {m} 的行为以及重复名称的影响。
由索引模型根据 Issue 内容生成。
描述
According to the documentation for the "SetName" property:
"The SetName property of TestCaseData allow setting the format string for the individual test case. So long as no format specifiers are used in the name, there will be no change in how this works."
With a name being assigned as "String name", we would expect no hierarchical change in the name of the test. However, the {m} section is being removed regardless. We can manually add the {m} format specifier in each case, however this conflicts with provided documentation.
There is an additional issue can resulted as part of this problem, when test case data is shared across multiple tests. If multiple items end up sharing the same name (due to the {m} being missing) it causes the remaining test information to become statically listed within MSTest, and several other Test Runners (including the Resharper test runner).
Code to replicate is included:
[TestFixture]
public class DemoTestClass
{
[Test, TestCaseSource(nameof(GetTestCases))]
public string objectUsedAsParamImpactsName(TestObjectClass obj)
{
Console.Write(obj.id);
return obj.name;
}
private static IEnumerable<TestCaseData> GetTestCases()
{
var data = new TestObjectClass() {name = "Test Name", id = 1};
var testCase = new TestCaseData(data);
testCase.SetName("String used as name");
testCase.Returns("Test Name");
yield return testCase;
}
[Test, TestCaseSource(nameof(GetStringTestCasesData))]
public string stringUsedAsParamShowsCorrectname(string str)
{
return str;
}
private static IEnumerable<TestCaseData> GetStringTestCasesData()
{
var testCase = new TestCaseData("Test Name");
testCase.SetName("String used as name");
testCase.Returns("Test Name");
yield return testCase;
}
public class TestObjectClass
{
public string name;
public int id;
}
}
- 主要语言
- Dockerfile
- 星标
- 601
- 派生
- 159
- 平均合并
- 22 小时 18 分钟
- 30 天内合并 PR
- 6
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nunit/docs 的其他 Issue
-
area:adapter type:newpage
难度 2/5 1-3 小时 新手友好度 82/100
-
Document why output from ASP.NET Core handlers (WebApplicationFactory) is not captured, and the workarounds可能已有人在做 @SeanKilleen 于 36 天前认领。 未关闭area:framework type:update
难度 2/5 1-3 小时 新手友好度 83/100
-
type:newpage
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 3/5 1-2 天 新手友好度 15/100
-
难度 4/5 3-5 天 新手友好度 35/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
audacity/audacity.github.io#118 ·
-
bug improve content
难度 1/5 1 小时以内 新手友好度 92/100
opensafely/documentation#2102 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 75/100
agentregistry-dev/website#69 ·
-
15.0
难度 2/5 1-3 小时 新手友好度 66/100
-
docs: add SECURITY.md vulnerability reporting policy可能已有人在做 @AK-Lmn 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 72/100
flisk-sh/linux2wasm#12 ·
维护者通常 1 天内回复