小编Eri*_*ler的帖子

使用具有 NSubstitute 自动数据属性的 AutoFixture 时测试丢失

按预期发现具有以下测试的测试类:

[Theory]
[AutoData]
public void MyDiscoveredTest() { }
Run Code Online (Sandbox Code Playgroud)

但是,缺少以下测试:

[Theory]
[AutoNSubstituteData]
public void MyMissingTest() { }
Run Code Online (Sandbox Code Playgroud)

有趣的是,如果我把 放在MyDiscoveredTest 后面 MyMissingTest,那么MyDiscoveredTest现在也丢失了。我尝试了 xUnit Visual Studio 运行程序和 xUnit 控制台运行程序,得到了相同的结果。

我的AutoNSubstituteData属性在这里定义:

internal class AutoNSubstituteDataAttribute : AutoDataAttribute
{
    internal AutoNSubstituteDataAttribute()
        : base(new Fixture().Customize(new AutoNSubstituteCustomization()))
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

一个相关的问题:由于AutoNSubstituteDataAttribute上述似乎是一个相当常见的属性,我想知道为什么它不包含在 AutoFixture.AutoNSubstitute 中。同样有用的是InlineAutoNSubstituteDataAttribute. 我应该提交这些请求请求吗?

使用的 Nuget 包版本:
AutoFixture 3.30.8
AutoFixture.Xunit2 3.30.8
AutoFixture.AutoNSubstitute 3.30.8
xunit 2.0.0
xunit.runner.visualstudio 2.0.0
xunit.runner.console 2.0.0
NSubstitute 1.8.2.0

我正在使用 Visual Studio 2013 Update 4 并面向 …

xunit autofixture nsubstitute

2
推荐指数
1
解决办法
2323
查看次数

“ git commit”的异常行为。预提交挂钩修改暂存文件时

以我的经验,git commit -a它的行为等同于git commit .但是,最近,我创建了一个pre-commit钩子,该钩子自动格式化我的源代码,现在git commit .有一些意想不到的副作用:提交的文件最终在工作目录和目录中被修改。提交命令完成后的索引。不会发生这种情况git commit -a。我试图了解运行时在幕后git commit .发生的情况,这导致这种情况发生,并查看是否有办法在我的预提交钩子脚本中正确处理它。

预提交挂钩:

git_toplevel=$(git rev-parse --show-toplevel)

git --no-pager diff -z --cached --name-only --diff-filter=ACMRT | $git_toplevel/meta/reformat.bash -s files
git --no-pager diff -z --name-only --diff-filter=ACMRT | xargs -0 --no-run-if-empty git add
Run Code Online (Sandbox Code Playgroud)

当前使用的是git版本1.8.3.1,但在最新版本中却看到了相同的行为。

这是在行的开头添加一个简单空格的命令序列:

[]$ git status
# On branch eroller/format-clean-filter
# Your branch is ahead of 'origin/eroller/format-clean-filter' by 1 commit.
#   (use "git push" to publish your local commits)
#
# Changes not …
Run Code Online (Sandbox Code Playgroud)

git code-formatting pre-commit-hook git-commit

2
推荐指数
1
解决办法
61
查看次数