Skip to content

Commit 3150433

Browse files
committed
Add the ability to solo a test in visual testing using [Solo] attribute
1 parent e6422d8 commit 3150433

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 single test method which will be "solo"ed during visual execution.
11+
/// This implies all other tests will be ignored.
12+
/// </summary>
13+
[AttributeUsage(AttributeTargets.Method)]
14+
[MeansImplicitUse]
15+
public class SoloAttribute : Attribute
16+
{
17+
}
18+
}

osu.Framework/Testing/TestBrowser.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,13 @@ private void finishLoad(TestScene newTest, Action onCompletion)
400400

401401
bool hadTestAttributeTest = false;
402402

403-
foreach (var m in newTest.GetType().GetMethods())
403+
var methods = newTest.GetType().GetMethods();
404+
405+
var solo = methods.FirstOrDefault(m => m.GetCustomAttribute(typeof(SoloAttribute), false) != null);
406+
if (solo != null)
407+
methods = new[] { solo };
408+
409+
foreach (var m in methods)
404410
{
405411
string name = m.Name;
406412

0 commit comments

Comments
 (0)