NCover似乎忽略了NUnit TestCase测试

时间:2013-12-14 09:57:47

标签: c# tdd nunit ncover

NCover似乎拒绝报告NUnit参数化测试的覆盖范围。

这很好:

    [Test]
    public void CreateImportTvShowsModelTests()
    {
        var importTvShowsModel = new ImportTvShowsModel(_fileUtilities, null, _tvShowLibrary, new ProgressModel());

        Assert.IsNotNull(importTvShowsModel.TvShowLibrary);
    }

在覆盖率报告中忽略了这一点:

    [TestCase(false, true, true)]
    [TestCase(false, false, true)]
    [TestCase(true, true, false)]
    [TestCase(false, false, true)]
    public void ToggleSelectAll(bool firstSelected, bool secondSelected, bool resultAllSelected)
    {
        // Go into some trouble to use actual DownloadedEpisodes (not mocks) because we need to validate
        // the IsSelected propery. Mocking the IsSelected property on DownloadedEpisode superseeds the whole purpose
        var matcher = MockRepository.GenerateMock<ISeasonAndEpisodeMatcher>();
        var tvShowsLibrary = MockRepository.GenerateMock<ITvShowsLibrary>();
        tvShowsLibrary.Expect(library => library.PossibleCorrespondingTvShows(string.Empty))
                      .IgnoreArguments()
                      .Return(new List<ITvShow>());

        var downloadedEpisode1 = new DownloadedEpisode(@"D:\bla.mkv", matcher, tvShowsLibrary) {IsSelected = firstSelected};
        var downloadedEpisode2 = new DownloadedEpisode(@"D:\bla.mkv", matcher, tvShowsLibrary) {IsSelected = secondSelected};

        var downloadedEpisodes = new ObservableCollection<IDownloadedEpisode> { downloadedEpisode1, downloadedEpisode2 };
        var importTvShowsModel = new ImportTvShowsModel(_fileUtilities, downloadedEpisodes, _tvShowLibrary, _progressModel);
        importTvShowsModel.ToggleSelectAll();

        Assert.AreEqual(resultAllSelected, downloadedEpisode1.IsSelected);
        Assert.AreEqual(resultAllSelected, downloadedEpisode2.IsSelected);
    }

当然,在这两种情况下,测试都会执行并且都会成功。

我是否可以通过报告参数化测试的覆盖范围来调整NCover?

1 个答案:

答案 0 :(得分:0)

更新到最新版本(4.5.2483。*),现在它是受支持的功能。 \ O /