diff --git a/Source/Core/IConeSuite.cs b/Source/Core/IConeSuite.cs index 49f9ac2..bdd9d07 100644 --- a/Source/Core/IConeSuite.cs +++ b/Source/Core/IConeSuite.cs @@ -8,10 +8,10 @@ public interface IConeEntity IEnumerable Categories { get; } } - public interface IConeSuite : IConeEntity - { - void AddCategories(IEnumerable categories); + public interface IConeSuite : IConeEntity + { + void AddCategories(IEnumerable categories); IRowSuite AddRowSuite(ConeMethodThunk thunk, string suiteName); void DiscoverTests(ConeTestNamer names); - } + } } diff --git a/Source/Runners/ConePadSuite.cs b/Source/Runners/ConePadSuite.cs index 0194157..5dc6567 100644 --- a/Source/Runners/ConePadSuite.cs +++ b/Source/Runners/ConePadSuite.cs @@ -152,5 +152,10 @@ class ConePadRowSuite : IRowSuite public void Run(Action, IConeFixture> collectResults) { collectResults(tests, fixture); } + + public void RunAll(Action, IConeFixture> collectResults) { + Run(collectResults); + Subsuites.Flatten(x => x.Subsuites).ForEach(x => x.Run(collectResults)); + } } } diff --git a/Specs/Cone.Specs/Cone.Specs.csproj b/Specs/Cone.Specs/Cone.Specs.csproj index a6d92c7..fc734e6 100644 --- a/Specs/Cone.Specs/Cone.Specs.csproj +++ b/Specs/Cone.Specs/Cone.Specs.csproj @@ -59,6 +59,7 @@ + diff --git a/Specs/Cone.Specs/Features/CategoryHandlingFeature.cs b/Specs/Cone.Specs/Features/CategoryHandlingFeature.cs new file mode 100644 index 0000000..1027874 --- /dev/null +++ b/Specs/Cone.Specs/Features/CategoryHandlingFeature.cs @@ -0,0 +1,44 @@ +using Cone.Core; +using Cone.Runners; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cone.Features +{ + [Feature("Category Handling")] + public class CategoryHandlingFeature + { + [Feature("Sugar Sweet")] + class ExampleSpec { + [Context("I'm Sugar", Category = "Sugar")] + public class ExampleSugarSpec + { + public void sugar() { } + + [Context("I'm Sweet", Category = "Sweet")] + public class ExampleSugarSweetSpec + { + public void sugar_sweet() { } + } + } + } + + public void categories_are_lexically_inherited() { + var suite = new ConePadSuiteBuilder(new DefaultObjectProvider()) + .BuildSuite(typeof(ExampleSpec)); + + var result = new List(); + suite.RunAll((tests, fixture) => { + result.AddRange(tests.Select(test => test.TestName.Name + " - " + string.Join(",", test.Categories))); + }); + + Check.That( + () => result.Contains("sugar - Sugar"), + () => result.Contains("sugar sweet - Sugar,Sweet") + ); + } + + } +}