Skip to content

Commit

Permalink
Merge pull request #6137 from peppy/solo-test
Browse files Browse the repository at this point in the history
Add the ability to solo a test in visual testing using `[Solo]` attribute
  • Loading branch information
smoogipoo authored Jan 27, 2024
2 parents d7dd556 + 51f0664 commit 20b6d9e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 18 additions & 0 deletions osu.Framework/Testing/SoloAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using JetBrains.Annotations;

namespace osu.Framework.Testing
{
/// <summary>
/// Denotes a single test method which will be "solo"ed during visual execution.
/// This implies all other tests will be ignored.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
[MeansImplicitUse]
public class SoloAttribute : Attribute
{
}
}
8 changes: 7 additions & 1 deletion osu.Framework/Testing/TestBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,13 @@ private void finishLoad(TestScene newTest, Action onCompletion)

bool hadTestAttributeTest = false;

foreach (var m in newTest.GetType().GetMethods())
var methods = newTest.GetType().GetMethods();

var soloTests = methods.Where(m => m.GetCustomAttribute(typeof(SoloAttribute), false) != null).ToArray();
if (soloTests.Any())
methods = soloTests;

foreach (var m in methods)
{
string name = m.Name;

Expand Down

0 comments on commit 20b6d9e

Please sign in to comment.