1

我有一个 .NET 项目,其中包含 2000 个用 NUnit 编写的单元测试,我想迁移到 Mono。

该项目在 Mac OS X 上使用 Mono 3.0.2/MonoDevelop 3.0.5 重新编译。我能够使用 MonoDevelop 的集成测试运行程序运行所有单元测试。

但是,我有很多标记为“LongRunning”的测试使用TestCaseAttribute

[TestCase(1, Category="LongRunning")]

但我无法使用单元测试选项(从菜单视图-> 垫-> 单元测试-> ...)排除它们。

在此处输入图像描述

包括/排除类别选项在那里,但尝试它们没有效果。

如何使用 MonoDevelop 测试运行程序排除 LongRunning 单元测试?

4

1 回答 1

1

好吧,这两个问题是分开的。这个补丁应该可以解决你的问题:

diff --git a/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs b/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs
index 385e50f..b2addd6 100644
--- a/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs
+++ b/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs
@@ -357,19 +357,19 @@ namespace MonoDevelop.NUnit
                        ITestFilter filter = null;
                        if (test != null) {
                                if (test is UnitTestGroup) {
-                                       filter = new TestNameFilter (CollectTests ((UnitTestGroup)test));
+                                       NUnitCategoryOptions categoryOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions));
+                                       if (categoryOptions != null && categoryOptions.EnableFilter && categoryOptions.Categories.Count > 0) {
+                                               string[] cats = new string [categoryOptions.Categories.Count];
+                                               categoryOptions.Categories.CopyTo (cats, 0);
+                                               filter = new CategoryFilter (cats);
+                                               if (categoryOptions.Exclude)
+                                                       filter = new NotFilter (filter);
+                                       } else {
+                                               filter = new TestNameFilter (CollectTests ((UnitTestGroup)test));
+                                       }
                                } else {
                                        filter = new TestNameFilter (test.TestId);
                                }
-                       } else {
-                               NUnitCategoryOptions categoryOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions));
-                               if (categoryOptions.EnableFilter && categoryOptions.Categories.Count > 0) {
-                                       string[] cats = new string [categoryOptions.Categories.Count];
-                                       categoryOptions.Categories.CopyTo (cats, 0);
-                                       filter = new CategoryFilter (cats);
-                                       if (categoryOptions.Exclude)
-                                               filter = new NotFilter (filter);
-                               }
                        }

                        RunData rd = new RunData ();

我也有其他问题的补丁(未写入设置),但即使它不涉及序列化代码,MD 也无法读回它保存的属性。我正在调查。

于 2013-01-20T02:25:58.453 回答