Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Build_WithTrimmableTypeMap_Succeeds ([Values] bool isRelease, [Value
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");

var intermediateDir = builder.Output.GetIntermediaryPath ("typemap");
DirectoryAssert.Exists (intermediateDir);
AssertTrimmableTypeMapOutputs (intermediateDir);
}

[Test]
Expand All @@ -50,7 +50,7 @@ public void Build_WithTrimmableTypeMap_IncrementalBuild ([Values] bool isRelease
Assert.IsTrue (builder.Build (proj), "First build should have succeeded.");

var intermediateDir = builder.Output.GetIntermediaryPath ("typemap");
DirectoryAssert.Exists (intermediateDir);
AssertTrimmableTypeMapOutputs (intermediateDir);

Assert.IsTrue (builder.Build (proj), "Second build should have succeeded.");

Expand Down Expand Up @@ -425,5 +425,18 @@ public ConcreteProvider (Android.Content.Context context) : base (context) { }
using var builder = CreateApkBuilder ();
Assert.IsTrue (builder.Build (proj), "Build should have succeeded — abstract types with protected ctors should not cause XAGTT7009.");
}

static void AssertTrimmableTypeMapOutputs (string typemapDir)
{
DirectoryAssert.Exists (typemapDir);
FileAssert.Exists (Path.Combine (typemapDir, "_Microsoft.Android.TypeMaps.dll"));
FileAssert.Exists (Path.Combine (typemapDir, "_Mono.Android.TypeMap.dll"));

var javaDir = Path.Combine (typemapDir, "java");
DirectoryAssert.Exists (javaDir, "Trimmable JCW Java output directory should exist.");

var javaFiles = Directory.GetFiles (javaDir, "*.java", SearchOption.AllDirectories);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 💡 Testing — Consider asserting the count or a specific expected file name rather than just IsNotEmpty. This would catch regressions where some JCW sources are silently dropped (e.g., if a future change causes only 1 of N expected files to be generated). For example, Assert.That (javaFiles.Length, Is.GreaterThanOrEqualTo (2), ...) or checking that a known type like MainActivity has a corresponding .java file.

Rule: Test assertions must be specific

Assert.IsNotEmpty (javaFiles, "At least one trimmable JCW Java source file should be generated.");
}
}
}