move sample package to example.com domain

pull/164/head
Aaron Trudeau 2023-06-30 18:34:47 -04:00
parent ad8643f7c6
commit 70eaa735aa
No known key found for this signature in database
GPG Key ID: 5EA8D416A3C71A20
40 changed files with 356 additions and 313 deletions

View File

@ -407,7 +407,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
projectPath: projectPath:
- unity-package-with-correct-tests/com.fake.notarealpackage - unity-package-with-correct-tests/com.example.testpackage
unityVersion: unityVersion:
- 2019.2.11f1 - 2019.2.11f1
testMode: testMode:
@ -446,7 +446,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
projectPath: projectPath:
- unity-package-with-correct-tests/com.fake.notarealpackage - unity-package-with-correct-tests/com.example.testpackage
unityVersion: unityVersion:
- 2019.2.11f1 - 2019.2.11f1
steps: steps:
@ -465,7 +465,7 @@ jobs:
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
testMode: all testMode: all
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+fake.notarealpackage.*,-*Tests*' coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+example.testpackage.*,-*Tests*'
packageMode: true packageMode: true
# Test implicit artifactsPath, by not setting it # Test implicit artifactsPath, by not setting it
@ -494,7 +494,7 @@ jobs:
unityVersion: unityVersion:
- 2019.2.11f1 - 2019.2.11f1
projectPath: projectPath:
- unity-package-with-correct-tests/com.fake.notarealpackage - unity-package-with-correct-tests/com.example.testpackage
steps: steps:
########################### ###########################
# Checkout # # Checkout #
@ -511,7 +511,7 @@ jobs:
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
testMode: editmode testMode: editmode
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+fake.notarealpackage.*,-*Tests*' coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+example.testpackage.*,-*Tests*'
artifactsPath: artifacts/packageeditmode artifactsPath: artifacts/packageeditmode
packageMode: true packageMode: true
@ -538,7 +538,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
projectPath: projectPath:
- unity-package-with-correct-tests/com.fake.notarealpackage - unity-package-with-correct-tests/com.example.testpackage
unityVersion: unityVersion:
- 2019.2.11f1 - 2019.2.11f1
steps: steps:
@ -557,7 +557,7 @@ jobs:
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
testMode: playmode testMode: playmode
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+fake.notarealpackage.*,-*Tests*' coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+example.testpackage.*,-*Tests*'
artifactsPath: artifacts/packageplaymode artifactsPath: artifacts/packageplaymode
packageMode: true packageMode: true
@ -586,7 +586,7 @@ jobs:
unityVersion: unityVersion:
- 2019.2.11f1 - 2019.2.11f1
projectPath: projectPath:
- unity-package-with-correct-tests/com.fake.notarealpackage - unity-package-with-correct-tests/com.example.testpackage
steps: steps:
########################### ###########################
# Checkout # # Checkout #

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: e3a65787d84893340b9dc38af5b7c31f guid: e3a65787d84893340b9dc38af5b7c31f
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -0,0 +1,16 @@
{
"name": "example.testpackage.Editor",
"rootNamespace": "",
"references": [
"example.testpackage.Runtime"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 6c6729c46a2a6594da2ce1182420ab81 guid: 6c6729c46a2a6594da2ce1182420ab81
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -1,18 +1,18 @@
using System; using System;
public class BasicCounter public class BasicCounter
{ {
public const int MaxCount = 10; public const int MaxCount = 10;
public BasicCounter(int count = 0) public BasicCounter(int count = 0)
{ {
Count = count; Count = count;
} }
public void Increment() public void Increment()
{ {
Count = Math.Min(MaxCount, Count + 1); Count = Math.Min(MaxCount, Count + 1);
} }
public int Count { get; private set; } public int Count { get; private set; }
} }

View File

@ -1,17 +1,17 @@
using UnityEngine; using UnityEngine;
public class SampleComponent : MonoBehaviour public class SampleComponent : MonoBehaviour
{ {
public BasicCounter Counter; public BasicCounter Counter;
void Start() void Start()
{ {
Counter = new BasicCounter(5); Counter = new BasicCounter(5);
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
Counter.Increment(); Counter.Increment();
} }
} }

View File

@ -1,18 +1,18 @@
using UnityEngine; using UnityEngine;
public class TimerComponent : MonoBehaviour public class TimerComponent : MonoBehaviour
{ {
public BasicCounter Counter = new BasicCounter(); public BasicCounter Counter = new BasicCounter();
public float Timer = 1f; public float Timer = 1f;
void Update() void Update()
{ {
Timer -= Time.deltaTime; Timer -= Time.deltaTime;
if (Timer > 0) if (Timer > 0)
return; return;
Counter.Increment(); Counter.Increment();
Timer = 1f; Timer = 1f;
} }
} }

View File

@ -0,0 +1,14 @@
{
"name": "example.testpackage.Runtime",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,38 +1,38 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using UnityEngine; using UnityEngine;
using UnityEngine.TestTools; using UnityEngine.TestTools;
namespace Tests namespace Tests
{ {
public class SampleEditModeTest public class SampleEditModeTest
{ {
[Test] [Test]
public void TestIncrement() public void TestIncrement()
{ {
// Given // Given
var counter = new BasicCounter(0); var counter = new BasicCounter(0);
// When // When
counter.Increment(); counter.Increment();
// Then // Then
Assert.AreEqual(1, counter.Count); Assert.AreEqual(1, counter.Count);
} }
[Test] [Test]
public void TestMaxCount() public void TestMaxCount()
{ {
// Given // Given
var counter = new BasicCounter(BasicCounter.MaxCount); var counter = new BasicCounter(BasicCounter.MaxCount);
// When // When
counter.Increment(); counter.Increment();
// Then // Then
Assert.AreEqual(BasicCounter.MaxCount, counter.Count); Assert.AreEqual(BasicCounter.MaxCount, counter.Count);
} }
} }
} }

View File

@ -0,0 +1,25 @@
{
"name": "example.testpackage.EditorTests",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"example.testpackage.Editor",
"example.testpackage.Runtime"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,31 +1,31 @@
using System.Collections; using System.Collections;
using NUnit.Framework; using NUnit.Framework;
using UnityEngine; using UnityEngine;
using UnityEngine.TestTools; using UnityEngine.TestTools;
namespace Tests namespace Tests
{ {
public class SampleComponentTest public class SampleComponentTest
{ {
private GameObject target; private GameObject target;
private SampleComponent component; private SampleComponent component;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
target = GameObject.Instantiate(new GameObject()); target = GameObject.Instantiate(new GameObject());
component = target.AddComponent<SampleComponent>(); component = target.AddComponent<SampleComponent>();
} }
[UnityTest] [UnityTest]
public IEnumerator TestIncrementOnUpdateAfterNextFrame() public IEnumerator TestIncrementOnUpdateAfterNextFrame()
{ {
// Save the current value, since it was updated after component Start() method called // Save the current value, since it was updated after component Start() method called
var count = component.Counter.Count; var count = component.Counter.Count;
// Skip frame and assert the new value // Skip frame and assert the new value
yield return null; yield return null;
Assert.AreEqual(count + 1, component.Counter.Count); Assert.AreEqual(count + 1, component.Counter.Count);
} }
} }
} }

View File

@ -1,42 +1,42 @@
using System.Collections; using System.Collections;
using NUnit.Framework; using NUnit.Framework;
using UnityEngine.TestTools; using UnityEngine.TestTools;
namespace Tests namespace Tests
{ {
public class SamplePlayModeTest public class SamplePlayModeTest
{ {
// A Test behaves as an ordinary method // A Test behaves as an ordinary method
[Test] [Test]
public void NewTestScriptSimplePasses() public void NewTestScriptSimplePasses()
{ {
// Given // Given
var counter = new BasicCounter(0); var counter = new BasicCounter(0);
// When // When
counter.Increment(); counter.Increment();
// Then // Then
Assert.AreEqual(1, counter.Count); Assert.AreEqual(1, counter.Count);
} }
// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
// `yield return null;` to skip a frame. // `yield return null;` to skip a frame.
[UnityTest] [UnityTest]
public IEnumerator NewTestScriptWithEnumeratorPasses() public IEnumerator NewTestScriptWithEnumeratorPasses()
{ {
// Given // Given
var counter = new BasicCounter(3); var counter = new BasicCounter(3);
// Use the Assert class to test conditions. // Use the Assert class to test conditions.
// Use yield to skip a frame. // Use yield to skip a frame.
yield return null; yield return null;
// When // When
counter.Increment(); counter.Increment();
// Then // Then
Assert.AreEqual(4, counter.Count); Assert.AreEqual(4, counter.Count);
} }
} }
} }

View File

@ -1,66 +1,66 @@
using System.Collections; using System.Collections;
using NUnit.Framework; using NUnit.Framework;
using UnityEngine; using UnityEngine;
using UnityEngine.TestTools; using UnityEngine.TestTools;
namespace Tests namespace Tests
{ {
public class TimerComponentTest public class TimerComponentTest
{ {
private GameObject target; private GameObject target;
private TimerComponent component; private TimerComponent component;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
target = GameObject.Instantiate(new GameObject()); target = GameObject.Instantiate(new GameObject());
component = target.AddComponent<TimerComponent>(); component = target.AddComponent<TimerComponent>();
} }
[UnityTest] [UnityTest]
public IEnumerator TestIncrementAfterSomeTime() public IEnumerator TestIncrementAfterSomeTime()
{ {
// Save the current value, since it was updated after component Start() method called // Save the current value, since it was updated after component Start() method called
var count = component.Counter.Count; var count = component.Counter.Count;
// Skip frame and assert the new value // Skip frame and assert the new value
yield return null; yield return null;
Assert.AreEqual(count, component.Counter.Count); Assert.AreEqual(count, component.Counter.Count);
yield return new WaitForSeconds(1.1f); yield return new WaitForSeconds(1.1f);
Assert.AreEqual(count + 1, component.Counter.Count); Assert.AreEqual(count + 1, component.Counter.Count);
yield return new WaitForSeconds(1.1f); yield return new WaitForSeconds(1.1f);
Assert.AreEqual(count + 2, component.Counter.Count); Assert.AreEqual(count + 2, component.Counter.Count);
} }
[UnityTest] [UnityTest]
public IEnumerator TestTimeScaleIsAffectingIncrement() public IEnumerator TestTimeScaleIsAffectingIncrement()
{ {
// Save the current value, since it was updated after component Start() method called // Save the current value, since it was updated after component Start() method called
var count = component.Counter.Count; var count = component.Counter.Count;
Time.timeScale = .5f; Time.timeScale = .5f;
// Skip frame and assert the new value // Skip frame and assert the new value
yield return null; yield return null;
Assert.AreEqual(count, component.Counter.Count); Assert.AreEqual(count, component.Counter.Count);
yield return WaitForRealSeconds(1.1f); yield return WaitForRealSeconds(1.1f);
Assert.AreEqual(count, component.Counter.Count); Assert.AreEqual(count, component.Counter.Count);
yield return WaitForRealSeconds(1.1f); yield return WaitForRealSeconds(1.1f);
Assert.AreEqual(count + 1, component.Counter.Count); Assert.AreEqual(count + 1, component.Counter.Count);
} }
// Skipping time ignoring Time.scale // Skipping time ignoring Time.scale
// https://answers.unity.com/questions/301868/yield-waitforseconds-outside-of-timescale.html // https://answers.unity.com/questions/301868/yield-waitforseconds-outside-of-timescale.html
public static IEnumerator WaitForRealSeconds(float time) public static IEnumerator WaitForRealSeconds(float time)
{ {
float start = Time.realtimeSinceStartup; float start = Time.realtimeSinceStartup;
while (Time.realtimeSinceStartup < start + time) while (Time.realtimeSinceStartup < start + time)
{ {
yield return null; yield return null;
} }
} }
} }
} }

View File

@ -0,0 +1,22 @@
{
"name": "example.testpackage.RuntimeTests",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"example.testpackage.Runtime"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,18 @@
{
"name": "com.example.testpackage",
"version": "0.0.1",
"displayName": "Test Package",
"description": "Test Package",
"unity": "2019.2",
"unityRelease": "11f1",
"keywords": [
"nothing"
],
"author": {
"name": "Example Author",
"email": "author@example.com",
"url": "example.com"
},
"type": "tool",
"hideInEditor": false
}

View File

@ -1,7 +1,7 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4232dbd3889ab6a4393e846291288fb0 guid: 4232dbd3889ab6a4393e846291288fb0
PackageManifestImporter: PackageManifestImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -1,6 +0,0 @@
{
"name": "fake.notarealpackage.Editor",
"references": [
"fake.notarealpackage.Runtime"
]
}

View File

@ -1,3 +0,0 @@
{
"name": "fake.notarealpackage.Runtime"
}

View File

@ -1,14 +0,0 @@
{
"name": "fake.notarealpackage.EditorTests",
"references": [
"fake.notarealpackage.Runtime",
"fake.notarealpackage.Editor"
],
"optionalUnityReferences": [
"TestAssemblies"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": []
}

View File

@ -1,11 +0,0 @@
{
"name": "fake.notarealpackage.RuntimeTests",
"references": [
"fake.notarealpackage.Runtime"
],
"optionalUnityReferences": [
"TestAssemblies"
],
"includePlatforms": [],
"excludePlatforms": []
}

View File

@ -1,18 +0,0 @@
{
"name": "com.fake.notarealpackage",
"version": "0.0.1",
"displayName": "Fake package",
"description": "Not a real package",
"unity": "2019.2",
"unityRelease": "11f1",
"keywords": [
"nothing"
],
"author": {
"name": "Not Real",
"email": "notreal@notarealemailendpoint.com",
"url": "https://github.com"
},
"type": "tool",
"hideInEditor": false
}