Skip to content

Commit

Permalink
[One .NET] Add Microsoft.Android-Tests unit tests
Browse files Browse the repository at this point in the history
A new version of Mono.Android-Tests has been added to run against the
.NET 6 SDK:

 * `tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj`

To support this, new .NET .csproj files have been added alongside all of
the existing legacy Xamarin.Android unit test library projects.  These
projects target `net5.0-android` and build against our .NET 6 SDK:

 * `src/Mono.Android/Test/Java.Interop-Tests/Java.Interop-Tests.NET.csproj`
 * `src/Mono.Android/Test/Mono.Android-Test.Library/Mono.Android-Test.Library.NET.csproj`
 * `src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.NET.csproj`
 * `tests/TestRunner.Core/TestRunner.Core.NET.csproj`
 * `tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj`

The `_CreateAar` target was being skipped for the new Java.Interop-Tests.NET
project, as it had no inputs.  As a result, the `Mono.Android-Test-classes.jar`
file required by these tests was not being included in the application project.
To fix this, I've added `@(AndroidJavaLibrary)` to `@(_CreateAarInputs)` so that
these items will also be considered as inputs for this target/task.
  • Loading branch information
pjcollins committed Nov 12, 2020
1 parent d6bea81 commit d8bde8a
Show file tree
Hide file tree
Showing 27 changed files with 280 additions and 297 deletions.
21 changes: 21 additions & 0 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,27 @@ stages:
artifactName: com.companyname.vsandroidapp-Signed.apk
artifactFolder: Default

- task: MSBuild@1
displayName: run Mono.Android.NET_Tests
inputs:
solution: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj
configuration: $(ApkTestConfiguration)
msbuildArguments: /t:RunDotNetInstrumentation
continueOnError: true

- script: >
mkdir -p $(Build.ArtifactStagingDirectory)/OneDotNet &&
cp "$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/net5.0-android/Mono.Android.NET_Tests-Signed.apk" "$(Build.ArtifactStagingDirectory)/OneDotNet"
displayName: copy apk/aab
continueOnError: true
- task: PublishTestResults@2
displayName: publish Mono.Android.NET_Tests results
inputs:
testResultsFormat: NUnit
testResultsFiles: TestResult-Mono.Android.NET_Tests-$(ApkTestConfiguration).xml
testRunTitle: Mono.Android.NET_Tests

- task: MSBuild@1
displayName: shut down emulator
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected override void AddSteps (Context context)
// Install essential tools, should they be missing
context.SetCondition (KnownConditions.EnsureEssential, true);

Steps.Add (new Step_InstallDotNetPreview ());
Steps.Add (new Step_GenerateFiles (atBuildStart: true, onlyRequired: true));
Steps.Add (new Step_PrepareExternalJavaInterop ());
}
Expand Down
4 changes: 2 additions & 2 deletions src-ThirdParty/NUnitLite/Internal/TestExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

using NUnit.Framework.Api;
#if !SILVERLIGHT && !NETCF
#if !SILVERLIGHT && !NETCF && !NET
using System.Runtime.Remoting.Messaging;
#endif

Expand All @@ -53,7 +53,7 @@ namespace NUnit.Framework.Internal
/// object on the top of the stack.
/// </summary>
public class TestExecutionContext
#if !SILVERLIGHT && !NETCF
#if !SILVERLIGHT && !NETCF && !NET
: ILogicalThreadAffinative
#endif
{
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Properties/AssemblyInfo.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Java.Interop-Tests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo("Mono.Android-TestsMultiDex, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo("Mono.Android-TestsAppBundle, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo("Mono.Android.NET-Tests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ projects.
<_CreateAarInputs Include="@(AndroidAsset)" />
<_CreateAarInputs Include="@(_AndroidResourceDest)" />
<_CreateAarInputs Include="@(AndroidEnvironment)" />
<_CreateAarInputs Include="@(AndroidJavaLibrary)" />
<_CreateAarInputs Include="@(EmbeddedJar)" />
<_CreateAarInputs Include="@(EmbeddedNativeLibrary)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static CodeBehindTests ()
CommonSampleLibraryRootDirectory = Path.GetFullPath (Path.Combine (XABuildPaths.TopDirectory, "tests", "CodeBehind", CommonSampleLibraryName));
TestOutputDir = Path.Combine (XABuildPaths.TestOutputDirectory, "temp", "CodeBehind");
if (Builder.UseDotNet) {
ProjectName += "DotNet";
ProjectName += ".NET";
}

generated_sources = new List <SourceFile> {
Expand Down
22 changes: 0 additions & 22 deletions src/Xamarin.Android.NUnitLite/Properties/AssemblyInfo.cs

This file was deleted.

35 changes: 35 additions & 0 deletions src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.NET.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk" >

<PropertyGroup>
<TargetFramework>net5.0-android</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.Android.NUnitLite</RootNamespace>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<AndroidApplication>false</AndroidApplication>
<NoStdLib>true</NoStdLib>
<!-- Disable XML doc warnings:
CS1570: XML comment has badly formed XML - 'Whitespace is not allowed at this location.'
CS1572: XML comment has a param tag for 'Bar', but there is no parameter by that name
CS1591: Missing XML comment for publicly visible type or member 'Foo'
-->
<NoWarn>1570;1572;1591</NoWarn>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\MonoAndroidFramework.props" />

<PropertyGroup>
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\$(Configuration)\lib\xamarin.android\xbuild-frameworks\Microsoft.Android\</OutputPath>
<DefineConstants>$(DefineConstants);NUNITLITE;CLR_4_0;NET_4_5;__MOBILE__;MONOTOUCH</DefineConstants>
<DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<GenerateDocumentation>True</GenerateDocumentation>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\src-ThirdParty\NUnitLite\**\*.cs" />
</ItemGroup>

</Project>
Loading

0 comments on commit d8bde8a

Please sign in to comment.