Skip to content

Commit 7b8a944

Browse files
Fix review issues and TRX publishing
- Restore XA4313 AndroidError for Xamarin.Android.NUnitLite in Common.targets - Restore NUnitLite in XA4313 test Values in BuildTest.cs - Restore GenerateAssemblyInfo=false and AssemblyInfo.cs in TestRunner.Core - Delete unused MainActivities and Main.axml layout - Move MyFragment to its own file (still needed by FragmentFixup tests) - Fix TRX publishing: copy device-pulled TRX to expected path instead of relying on --logger trx which doesn't work with Microsoft.Android.Run Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4c1e796 commit 7b8a944

10 files changed

Lines changed: 70 additions & 144 deletions

File tree

build-tools/automation/yaml-templates/apk-instrumentation.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,25 @@ steps:
2020
project: ${{ parameters.project }}
2121
arguments: >-
2222
--no-build
23-
--logger "trx;LogFileName=${{ parameters.testName }}.trx"
24-
--results-directory ${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/TestResults
2523
-bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/run-${{ parameters.testName }}.binlog
2624
-c ${{ parameters.configuration }} ${{ parameters.extraBuildArgs }}
2725
condition: ${{ parameters.condition }}
2826
continueOnError: true
2927

28+
- script: |
29+
RESULTS_DIR="${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/TestResults"
30+
mkdir -p "$RESULTS_DIR"
31+
TRX_FILE=$(find "$TMPDIR/AndroidTestResults" -name "*.trx" -newer "${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/run-${{ parameters.testName }}.binlog" 2>/dev/null | head -1)
32+
if [ -n "$TRX_FILE" ]; then
33+
cp "$TRX_FILE" "$RESULTS_DIR/${{ parameters.testName }}.trx"
34+
echo "Copied TRX: $TRX_FILE -> $RESULTS_DIR/${{ parameters.testName }}.trx"
35+
else
36+
echo "##[warning]No TRX file found in $TMPDIR/AndroidTestResults"
37+
fi
38+
displayName: copy ${{ parameters.testName }} trx
39+
condition: ${{ parameters.condition }}
40+
continueOnError: true
41+
3042
- script: >
3143
DEST="$(Build.StagingDirectory)/Test${{ parameters.configuration }}/${{ parameters.artifactFolder }}/" &&
3244
mkdir -p "$DEST" &&

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ public void XA1018 ([Values] AndroidRuntime runtime)
17041704
}
17051705

17061706
[Test]
1707-
public void XA4313 ([Values ("OpenTK-1.0")] string reference, [Values] AndroidRuntime runtime)
1707+
public void XA4313 ([Values ("OpenTK-1.0", "Xamarin.Android.NUnitLite")] string reference, [Values] AndroidRuntime runtime)
17081708
{
17091709
bool isRelease = runtime == AndroidRuntime.NativeAOT;
17101710
if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) {

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,12 @@ because xbuild doesn't support framework reference assemblies.
879879
ResourceName="XA4313"
880880
FormatArguments="OpenTK-1.0;Xamarin.Legacy.OpenTK"
881881
/>
882+
<AndroidError
883+
Condition=" '%(Reference.Identity)' == 'Xamarin.Android.NUnitLite' "
884+
Code="XA4313"
885+
ResourceName="XA4313"
886+
FormatArguments="Xamarin.Android.NUnitLite;Xamarin.Legacy.NUnitLite"
887+
/>
882888
</Target>
883889

884890
<Target Name="_CheckDuplicateJavaLibraries" DependsOnTargets="_GetLibraryImports">

tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/MainActivity.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
<Compile Include="Xamarin.Android.Net\AndroidMessageHandlerTests.cs" />
147147
<Compile Include="Xamarin.Android.Net\AndroidMessageHandlerNegotiateAuthenticationTests.cs" />
148148
<Compile Include="Xamarin.Android.Net\HttpClientIntegrationTests.cs" />
149-
<Compile Include="Xamarin.Android.RuntimeTests\MainActivity.cs" />
149+
<Compile Include="Xamarin.Android.RuntimeTests\MyFragment.cs" />
150150
<Compile Include="Xamarin.Android.RuntimeTests\MyIntent.cs" />
151151
<Compile Include="Xamarin.Android.RuntimeTests\NonJavaObject.cs" />
152152
<Compile Include="Xamarin.Android.RuntimeTests\NUnitInstrumentation.cs" />
@@ -187,9 +187,6 @@
187187
<AndroidResource Include="Resources\layout\FragmentFixup.axml">
188188
<Link>Resources\layout\FragmentFixup.axml</Link>
189189
</AndroidResource>
190-
<AndroidBoundLayout Include="Resources\layout\Main.axml">
191-
<Link>Resources\layout\Main.axml</Link>
192-
</AndroidBoundLayout>
193190
</ItemGroup>
194191

195192
<ItemGroup>

tests/Mono.Android-Tests/Mono.Android-Tests/Resources/layout/Main.axml

Lines changed: 0 additions & 67 deletions
This file was deleted.

tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/MainActivity.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Android.App;
2+
using Android.Views;
3+
using Android.Widget;
4+
5+
namespace Xamarin.Android.RuntimeTests
6+
{
7+
#if __ANDROID_11__
8+
public class MyFragment : Fragment {
9+
public override View OnCreateView (LayoutInflater inflater, ViewGroup? container, Bundle? savedInstanceState)
10+
{
11+
return new TextView (Activity) {
12+
Text = "via fragment!",
13+
};
14+
}
15+
}
16+
#endif // ANDROID_11
17+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using Android.App;
4+
5+
// Information about this assembly is defined by the following attributes.
6+
// Change them to the values specific to your project.
7+
8+
[assembly: AssemblyTitle("TestRunner.Core")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("")]
13+
[assembly: AssemblyCopyright("Microsoft, Inc")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
18+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
19+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
20+
21+
[assembly: AssemblyVersion("1.0.0")]
22+
23+
// The following attributes are used to specify the signing key for the assembly,
24+
// if desired. See the Mono documentation for more information about signing.
25+
26+
//[assembly: AssemblyDelaySign(false)]
27+
//[assembly: AssemblyKeyFile("")]
28+
29+
// Needed to read the device serial number
30+
[assembly: UsesPermission (Name = Android.Manifest.Permission.ReadPhoneState)]

tests/TestRunner.Core/TestRunner.Core.NET.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<SupportedOSPlatformVersion>$(AndroidMinimumDotNetApiLevel)</SupportedOSPlatformVersion>
66
<OutputType>Library</OutputType>
77
<RootNamespace>Xamarin.Android.UnitTests</RootNamespace>
8+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
89
<Nullable>enable</Nullable>
910
<ImplicitUsings>enable</ImplicitUsings>
1011
</PropertyGroup>

0 commit comments

Comments
 (0)