A game framework written with osu! in mind.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add attribute to mark visual tests that should only run via nUnit

+37 -7
+5 -3
osu.Framework.Tests/Visual/Containers/TestSceneCompositeMutability.cs osu.Framework.Tests/Containers/TestSceneCompositeMutability.cs
··· 6 6 using NUnit.Framework; 7 7 using osu.Framework.Allocation; 8 8 using osu.Framework.Graphics; 9 - using osu.Framework.Graphics.Containers; 10 9 using osu.Framework.Graphics.Shapes; 10 + using osu.Framework.Testing; 11 + using osu.Framework.Tests.Visual; 11 12 12 - namespace osu.Framework.Tests.Visual.Containers 13 + namespace osu.Framework.Tests.Containers 13 14 { 15 + [HeadlessTest] 14 16 public class TestSceneCompositeMutability : FrameworkTestScene 15 17 { 16 18 [TestCase(TestThread.External, false)] ··· 135 137 } 136 138 } 137 139 138 - private class BlockableLoadContainer : Container 140 + private class BlockableLoadContainer : Framework.Graphics.Containers.Container 139 141 { 140 142 /// <summary> 141 143 /// Allows continuation to a point in the <see cref="LoadState.Loading"/> state which invokes <see cref="OnLoading"/>.
+4 -1
osu.Framework.Tests/Visual/Containers/TestSceneContainerState.cs osu.Framework.Tests/Containers/TestSceneContainerState.cs
··· 10 10 using osu.Framework.Graphics.Containers; 11 11 using osu.Framework.Graphics.Shapes; 12 12 using osu.Framework.Graphics.Sprites; 13 + using osu.Framework.Testing; 14 + using osu.Framework.Tests.Visual; 13 15 14 - namespace osu.Framework.Tests.Visual.Containers 16 + namespace osu.Framework.Tests.Containers 15 17 { 16 18 [System.ComponentModel.Description("ensure valid container state in various scenarios")] 19 + [HeadlessTest] 17 20 public class TestSceneContainerState : FrameworkTestScene 18 21 { 19 22 /// <summary>
+3 -1
osu.Framework.Tests/Visual/Containers/TestSceneLoadComponentAsync.cs osu.Framework.Tests/Containers/TestSceneLoadComponentAsync.cs
··· 8 8 using osu.Framework.Graphics; 9 9 using osu.Framework.Graphics.Containers; 10 10 using osu.Framework.Testing; 11 + using osu.Framework.Tests.Visual; 11 12 12 - namespace osu.Framework.Tests.Visual.Containers 13 + namespace osu.Framework.Tests.Containers 13 14 { 15 + [HeadlessTest] 14 16 public class TestSceneLoadComponentAsync : FrameworkTestScene 15 17 { 16 18 private AsyncChildLoadingComposite composite;
+4 -1
osu.Framework.Tests/Visual/Sprites/TestSceneSpriteTextPresence.cs osu.Framework.Tests/Sprites/TestSceneSpriteTextPresence.cs
··· 8 8 using osu.Framework.Graphics.Shapes; 9 9 using osu.Framework.Graphics.Sprites; 10 10 using osu.Framework.MathUtils; 11 + using osu.Framework.Testing; 12 + using osu.Framework.Tests.Visual; 11 13 using osuTK.Graphics; 12 14 13 - namespace osu.Framework.Tests.Visual.Sprites 15 + namespace osu.Framework.Tests.Sprites 14 16 { 17 + [HeadlessTest] 15 18 public class TestSceneSpriteTextPresence : FrameworkTestScene 16 19 { 17 20 /// <summary>
+18
osu.Framework/Testing/HeadlessTestAttribute.cs
··· 1 + // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2 + // See the LICENCE file in the repository root for full licence text. 3 + 4 + using System; 5 + using JetBrains.Annotations; 6 + 7 + namespace osu.Framework.Testing 8 + { 9 + /// <summary> 10 + /// Denotes a "visual" test which should only be run in a headless context. 11 + /// This will stop the test from showing up in a <see cref="TestBrowser"/>. 12 + /// </summary> 13 + [AttributeUsage(AttributeTargets.Class)] 14 + [MeansImplicitUse] 15 + public class HeadlessTestAttribute : Attribute 16 + { 17 + } 18 + }
+3 -1
osu.Framework/Testing/TestBrowser.cs
··· 63 63 //we want to build the lists here because we're interested in the assembly we were *created* on. 64 64 foreach (Assembly asm in assemblies.ToList()) 65 65 { 66 - var tests = asm.GetLoadableTypes().Where(t => t.IsSubclassOf(typeof(TestScene)) && !t.IsAbstract && t.IsPublic).ToList(); 66 + var tests = asm.GetLoadableTypes().Where(isValidVisualTest).ToList(); 67 67 68 68 if (!tests.Any()) 69 69 { ··· 77 77 78 78 TestTypes.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal)); 79 79 } 80 + 81 + private bool isValidVisualTest(Type t) => t.IsSubclassOf(typeof(TestScene)) && !t.IsAbstract && t.IsPublic && !t.GetCustomAttributes<HeadlessTestAttribute>().Any(); 80 82 81 83 private void updateList(ValueChangedEvent<Assembly> args) 82 84 {