Skip to content

feat: skip Test if PerformanceAttribute exists. #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
634 changes: 0 additions & 634 deletions RuntimeUnitTestToolkit/Assembly-CSharp.csproj

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"name": "RuntimeUnitTestToolkit",
"references": [
],
"optionalUnityReferences": [
"TestAssemblies"
],
Expand All @@ -12,5 +10,5 @@
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}
"noEngineReferences": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ static IEnumerable<Type> GetTestTargetTypes()

foreach (var method in item.GetMethods())
{
// Skip Test if PerformanceAttribute exists.
var attributes = method.GetCustomAttributes();
if (attributes.Any(x => string.Equals(x.GetType().FullName, "Unity.PerformanceTesting.PerformanceAttribute", StringComparison.OrdinalIgnoreCase)))
{
Debug.Log("[SKIP]" + method.Name + " has PerformanceAttribute.");
continue;
}

TestAttribute t1 = null;
try
{
Expand Down
44 changes: 44 additions & 0 deletions RuntimeUnitTestToolkit/Assets/Scripts/Tests/PerfTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using NUnit.Framework;
using Unity.PerformanceTesting;
using UnityEngine;

namespace SampleUnitTest
{
public class PerfTest
{
AnotherClass another;
string anotherJson;

public PerfTest()
{
another = new AnotherClass();
anotherJson = JsonUtility.ToJson(another);
}

[Test, Performance]
public void DummySerialize()
{
Measure.Method(() =>
{
JsonUtility.ToJson(another);
})
.WarmupCount(10)
.IterationsPerMeasurement(10000)
.MeasurementCount(10)
.Run();
}

[Test, Performance]
public void DummyDeserialize()
{
Measure.Method(() =>
{
JsonUtility.FromJson<AnotherClass>(anotherJson);
})
.WarmupCount(10)
.IterationsPerMeasurement(10000)
.MeasurementCount(10)
.Run();
}
}
}
12 changes: 12 additions & 0 deletions RuntimeUnitTestToolkit/Assets/Scripts/Tests/PerfTest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion RuntimeUnitTestToolkit/Assets/Scripts/Tests/Tests.asmdef
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
{
"name": "Tests",
"references": [
"Unity.PerformanceTesting"
],
"optionalUnityReferences": [
"TestAssemblies"
]
Expand Down
639 changes: 0 additions & 639 deletions RuntimeUnitTestToolkit/NewAssembly.csproj

This file was deleted.

1 change: 1 addition & 0 deletions RuntimeUnitTestToolkit/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.ide.vscode": "1.2.5",
"com.unity.test-framework": "1.1.33",
"com.unity.test-framework.performance": "3.0.3",
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.9",
"com.unity.ugui": "1.0.0"
}
Expand Down
10 changes: 10 additions & 0 deletions RuntimeUnitTestToolkit/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
},
"url": "https://packages.unity.com"
},
"com.unity.test-framework.performance": {
"version": "3.0.3",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.31",
"com.unity.modules.jsonserialize": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.toolchain.win-x86_64-linux-x86_64": {
"version": "2.0.9",
"depth": 0,
Expand Down
638 changes: 0 additions & 638 deletions RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.Editor.csproj

This file was deleted.

Loading