-
Notifications
You must be signed in to change notification settings - Fork 62
Automated Test improvements #41
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
Open
SkowronskiAndrew
wants to merge
4
commits into
main
Choose a base branch
from
testwork
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
598605a
Split WebBundle testing into its own class
SkowronskiAndrew 95e5cf7
Split UnityDataToolTests.cs to multiple source files
SkowronskiAndrew b299726
Adding some comments based on study of the test framework
SkowronskiAndrew 1335a36
And initial test for Addressables BuildLayout import support
SkowronskiAndrew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
TestCommon/Data/AddressableBuildLayouts/buildlayout_2025.01.28.16.35.01.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
TestCommon/Data/AddressableBuildLayouts/buildlayout_2025.01.28.16.51.14.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| using System; | ||
| using Microsoft.Data.Sqlite; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace UnityDataTools.UnityDataTool.Tests; | ||
|
|
||
| #pragma warning disable NUnit2005, NUnit2006 | ||
|
|
||
| public class AddressablesBuildLayoutTests | ||
| { | ||
| private string m_TestOutputFolder; | ||
| private string m_TestDataFolder; | ||
|
|
||
| [OneTimeSetUp] | ||
| public void OneTimeSetup() | ||
| { | ||
| m_TestOutputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, "test_folder"); | ||
| m_TestDataFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, "Data"); | ||
| Directory.CreateDirectory(m_TestOutputFolder); | ||
| Directory.SetCurrentDirectory(m_TestOutputFolder); | ||
| } | ||
|
|
||
| [TearDown] | ||
| public void Teardown() | ||
| { | ||
| SqliteConnection.ClearAllPools(); | ||
|
|
||
| var testDir = new DirectoryInfo(m_TestOutputFolder); | ||
| testDir.EnumerateFiles() | ||
| .ToList().ForEach(f => f.Delete()); | ||
| testDir.EnumerateDirectories() | ||
| .ToList().ForEach(d => d.Delete(true)); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Analyze_BuildLayout_ContainsExpectedSQLContent() | ||
| { | ||
| // This folder contains reference files from two builds of the "AudioExample" | ||
| // Addressables test project. | ||
| // The test confirms some expected content in the database | ||
| var path = Path.Combine(m_TestDataFolder, "AddressableBuildLayouts"); | ||
|
|
||
| var databasePath = Path.Combine(m_TestOutputFolder, "database.db"); | ||
|
|
||
| Assert.AreEqual(0, await Program.Main(new string[] { "analyze", path, "-p", "*.json" })); | ||
| using var db = new SqliteConnection(new SqliteConnectionStringBuilder | ||
| { | ||
| DataSource = databasePath, | ||
| Mode = SqliteOpenMode.ReadWriteCreate, | ||
| Pooling = false, | ||
| ForeignKeys = false, | ||
| }.ConnectionString); | ||
| db.Open(); | ||
|
|
||
| using var cmd = db.CreateCommand(); | ||
|
|
||
| // Sanity check some expected content in the output SQLite database | ||
| cmd.CommandText = | ||
| @"SELECT | ||
| (SELECT COUNT(*) FROM addressables_builds), | ||
| (SELECT COUNT(*) FROM addressables_builds WHERE name = ""buildlayout_2025.01.28.16.35.01.json""), | ||
| (SELECT unity_version FROM addressables_builds WHERE id = 1), | ||
| (SELECT package_version FROM addressables_builds WHERE id = 1), | ||
| (SELECT COUNT(*) FROM addressables_build_bundles WHERE build_id = 1 and name = ""samplepack1_assets_0.bundle""), | ||
| (SELECT file_size FROM addressables_build_bundles WHERE build_id = 2 and name = ""samplepack1_assets_0.bundle""), | ||
| (SELECT packing_mode FROM addressables_build_groups WHERE build_id = 1 and name = ""SamplePack1""), | ||
| (SELECT COUNT(*) FROM asset_bundles)"; | ||
|
|
||
| using var reader = cmd.ExecuteReader(); | ||
| reader.Read(); | ||
|
|
||
| Assert.AreEqual(2, reader.GetInt32(0), "Unexpected number of builds"); | ||
| Assert.AreEqual(1, reader.GetInt32(1), "Failed to find build matching reference filename"); | ||
| Assert.AreEqual("6000.1.0b2", reader.GetString(2), "Unexpected Unity Version"); | ||
| Assert.AreEqual("com.unity.addressables: 2.2.2", reader.GetString(3), "Unexpected Addressables version"); | ||
| Assert.AreEqual(1, reader.GetInt32(4), "Expected to find specific AssetBundle by name"); | ||
| Assert.AreEqual(33824, reader.GetInt32(5), "Unexpected size for specific AssetBundle in build 2"); | ||
| Assert.AreEqual("PackSeparately", reader.GetString(6), "Unexpected packing_mode for group"); | ||
| Assert.AreEqual(0, reader.GetInt32(7), "Expected no AssetBundles found in reference folder"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above is the only new test code.
The rest of the changes are just shuffling existing tests into better structure