Skip to content

Commit 20b6d9e

Browse files
authored
Merge pull request #6137 from peppy/solo-test
Add the ability to solo a test in visual testing using `[Solo]` attribute
2 parents d7dd556 + 51f0664 commit 20b6d9e

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 soloTests = methods.Where(m => m.GetCustomAttribute(typeof(SoloAttribute), false) != null).ToArray();
406+
if (soloTests.Any())
407+
methods = soloTests;
408+
409+
foreach (var m in methods)
404410
{
405411
string name = m.Name;
406412

0 commit comments

Comments
 (0)