Skip to content
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

Update Unit tests to use the 'TestName' property #9664

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public void CheckOldResourceDesignerIsNotUsed ([Values (true, false)] bool isRel
};
proj.SetProperty ("AndroidUseIntermediateDesignerFile", "True");
proj.SetProperty ("AndroidUseManagedDesignTimeResourceGenerator", "False");
using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
dellis1972 marked this conversation as resolved.
Show resolved Hide resolved
var designer = Path.Combine ("Resources", "Resource.designer" + proj.Language.DefaultDesignerExtension);
if (File.Exists (designer))
File.Delete (Path.Combine (Root, b.ProjectDirectory, designer));
Expand All @@ -582,7 +582,7 @@ public void CheckOldResourceDesignerWithWrongCasingIsRemoved ([Values (true, fal
};
proj.SetProperty ("AndroidUseIntermediateDesignerFile", "True");
proj.SetProperty ("AndroidResgenFile", "Resources\\Resource.designer" + proj.Language.DefaultDesignerExtension);
using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
var designer = proj.Sources.FirstOrDefault (x => x.Include() == "Resources\\Resource.designer" + proj.Language.DefaultDesignerExtension);
designer = designer ?? proj.OtherBuildItems.FirstOrDefault (x => x.Include () == "Resources\\Resource.designer" + proj.Language.DefaultDesignerExtension);
Assert.IsNotNull (designer, $"Failed to retrieve the Resource.designer.{proj.Language.DefaultDesignerExtension}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ public void BuildAfterUpgradingNuget ()
Version = "1.6.1.5",
});

using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
//[TearDown] will still delete if test outcome successful, I need logs if assertions fail but build passes
b.CleanupAfterSuccessfulBuild =
b.CleanupOnDispose = false;
Expand Down Expand Up @@ -841,7 +841,7 @@ public void Dispose ()
}
}
}" });
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) {
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Build (proj), "Build should have failed with XA4212.");
StringAssertEx.Contains ($"error : XA4", builder.LastBuildOutput, "Error should be XA4212");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ public void BuildApplicationWithLibraryAndClean ([Values (false, true)] bool isR
ProjectName = "App1",
References = { new BuildItem ("ProjectReference", "..\\Library1\\Library1.csproj") },
};
var projectPath = Path.Combine ("temp", TestContext.CurrentContext.Test.Name);
var projectPath = Path.Combine ("temp", TestName);
using (var libb = CreateDllBuilder (Path.Combine (projectPath, lib.ProjectName), false, false)) {
Assert.IsTrue (libb.Build (lib), "Build of library should have succeeded");
using (var b = CreateApkBuilder (Path.Combine (projectPath, proj.ProjectName), false, false)) {
Expand Down Expand Up @@ -1382,7 +1382,7 @@ public void BuildAppCheckDebugSymbols ()
{
AssertCommercialBuild (); // FIXME: when Fast Deployment isn't available, we would need to use `llvm-objcopy` to extract the debug symbols

var path = Path.Combine ("temp", TestContext.CurrentContext.Test.Name);
var path = Path.Combine ("temp", TestName);
var lib = new XamarinAndroidLibraryProject () {
IsRelease = false,
ProjectName = "Library1",
Expand Down Expand Up @@ -1552,7 +1552,7 @@ public void BuildWithJavaToolOptions ()
[Test]
public void LibraryWithGenericAttribute ()
{
var path = Path.Combine ("temp", TestContext.CurrentContext.Test.Name);
var path = Path.Combine ("temp", TestName);
var lib = new XamarinAndroidLibraryProject {
ProjectName = "Library1",
IsRelease = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public void BuildWithNativeLibraryUnknownAbi ()
};
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86");

using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) {
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Build (proj), "Build should have failed.");
Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, $"error XA4301: Cannot determine ABI of native library 'not-a-real-abi{Path.DirectorySeparatorChar}libtest.so'. Move this file to a directory with a valid Android ABI name such as 'libs/armeabi-v7a/'."),
Expand Down Expand Up @@ -502,7 +502,7 @@ public void AndroidLibraryProjectsZipWithOddPaths ()
TextContent = () => $@"
<Project>
<PropertyGroup>
<IntermediateOutputPath>$(MSBuildThisFileDirectory)../{TestContext.CurrentContext.Test.Name}/obj/$(Configuration)/foo/</IntermediateOutputPath>
<IntermediateOutputPath>$(MSBuildThisFileDirectory)../{TestName}/obj/$(Configuration)/foo/</IntermediateOutputPath>
</PropertyGroup>
</Project>"
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public void ManifestDataPathError ()
</activity>
</application>");
proj.AndroidManifest = s;
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) {
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Build (proj), "Build should have failed.");
var messages = builder.LastBuildOutput.SkipWhile (x => !x.StartsWith ("Build FAILED.", StringComparison.Ordinal));
Expand Down Expand Up @@ -621,7 +621,7 @@ public void ManifestPlaceHolders2 ()
Assert.AreNotEqual (proj.AndroidManifest, s, "#0");
proj.SetProperty ("AndroidManifestPlaceholders", "FOOBARNAME=AAAAAAAA");
proj.AndroidManifest = s;
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name), false, false)) {
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName), false, false)) {
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");
var manifest = builder.Output.GetIntermediaryAsText (Root, "android/AndroidManifest.xml");
Assert.IsTrue (manifest.Contains ("AAAAAAAA"), "#1");
Expand Down Expand Up @@ -745,7 +745,7 @@ public void MergeLibraryManifest ()
}
data = ms.ToArray ();
}
var path = Path.Combine ("temp", TestContext.CurrentContext.Test.Name);
var path = Path.Combine ("temp", TestName);
var lib = new XamarinAndroidBindingProject () {
ProjectName = "Binding1",
AndroidClassParser = "class-parse",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public void CheckSignApk ([Values(true, false)] bool useApkSigner, [Values(true,
} else {
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86");
}
using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
jonathanpeppers marked this conversation as resolved.
Show resolved Hide resolved
var bin = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath);
Assert.IsTrue (b.Build (proj), "First build failed");
b.AssertHasNoWarnings ();
Expand Down
4 changes: 2 additions & 2 deletions tests/MSBuildDeviceIntegration/Tests/InstallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void InstallErrorCode ()
};
proj.SetAndroidSupportedAbis (abi);

using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) {
builder.ThrowOnBuildFailure = false;
if (!builder.Install (proj)) {
Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, "ADB0020"), "Should receive ADB0020 error code.");
Expand All @@ -247,7 +247,7 @@ public void ToggleFastDev ()
}
};

using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (builder.Install (proj), "Install should have succeeded.");
var directorylist = GetContentFromAllOverrideDirectories (proj.PackageName, DeviceAbi);
StringAssert.Contains ($"{proj.ProjectName}.dll", directorylist, $"{proj.ProjectName}.dll should exist in the .__override__ directory.");
Expand Down
Loading