排除MonoDevelop 3.0中的单元测试类别

时间:2013-01-17 22:05:49

标签: macos mono nunit monodevelop

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

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

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

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

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

enter image description here

包含/排除类别选项,但尝试它们没有效果。

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

1 个答案:

答案 0 :(得分: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也无法读回它保存的属性。我正在调查那个。

相关问题