Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Enabled unit-tests for Android and iOS #137

Merged
merged 3 commits into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
Please take a moment to fill out the following:

Fixes # .
Fixes issue #

Changes Proposed in this pull request:
-
-
-


### PR Checklist ###

- [ ] Has tests (if omitted, state reason in description)
- [ ] Rebased on top of master at time of PR
- [ ] Consolidate commits as makes sense
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.user
*.userosscache
*.sln.docstates
nunit-summary*

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand All @@ -20,6 +21,8 @@ x86/
bld/
[Bb]in/
[Oo]bj/
[Tt]ools
unit-test-tools

# Visual Studio 2015 cache/options directory
.vs/
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ Get started by reading through the [Connectivity Plugin documentation](https://j
* Blog: [MotzCod.es](http://motzcod.es), [Micro Blog](http://motz.micro.blog)
* Podcasts: [Merge Conflict](http://mergeconflict.fm), [Coffeehouse Blunders](http://blunders.fm), [The Xamarin Podcast](http://xamarinpodcast.com)
* Video: [The Xamarin Show on Channel 9](http://xamarinshow.com), [YouTube Channel](https://www.youtube.com/jamesmontemagno)
# Contribution

Thanks you for your interest in contributing to Settings plugin! In this section we'll outline what you need to know about contributing and how to get started.

### Bug Fixes
Please browse open issues, if you're looking to fix something, it's possible that someone already reported it. Additionally you select any `up-for-grabs` items

### Pull requests
Please fill out the pull request template when you send one.
Run tests to make sure your changes don't break any unit tests. Follow these instructions to run tests -

**iOS**
- Navigate to _tests/Connectivity.Tests.iOS_
- Execute `make run-simulator-tests`

**Android**

Execute `./build.sh --target RunDroidTests` from the project root
## License
The MIT License (MIT) see [License file](LICENSE)
25 changes: 25 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var TARGET = Argument ("target", Argument ("t", "Default"));
var VERSION = EnvironmentVariable ("APPVEYOR_BUILD_VERSION") ?? Argument("version", "0.0.9999");
var CONFIG = Argument("configuration", EnvironmentVariable ("CONFIGURATION") ?? "Release");
var SLN = "./src/Connectivity.sln";
var NUNIT_RESULT_PARSER = "./nunit-summary.exe";

Task("Libraries").Does(()=>
{
Expand Down Expand Up @@ -29,6 +30,30 @@ Task ("NuGet")
//Build the component, which build samples, nugets, and libraries
Task ("Default").IsDependentOn("NuGet");

Task ("RunDroidTests")
.IsDependentOn("DownloadUnitTestTools")
.Does(()=>
{
var outputPath = MakeAbsolute(Directory("./tests/Connectivity.Tests.Android/bin/Debug"));
MSBuild("./tests/Connectivity.Tests.Android/Connectivity.Tests.Android.csproj",
new MSBuildSettings()
.WithProperty("MyBuildOutputPath", outputPath.ToString())
.WithTarget("SignAndroidPackage")
.WithTarget("RunUnitTests"));
var exe = MakeAbsolute(File(NUNIT_RESULT_PARSER));
StartProcess(exe.ToString(), outputPath.CombineWithFilePath("test-results-Debug.xml").ToString());
});

Task("DownloadUnitTestTools")
.Does(()=>{
var exe = MakeAbsolute(File(NUNIT_RESULT_PARSER));
if(!FileExists(exe.ToString()))
DownloadFile("https://github.com/prashantvc/nunit-summary/releases/download/0.4/nunit-summary.exe","nunit-summary.exe");
else
Information("nunit-summary.exe exists");

});

Task ("Clean").Does (() =>
{
CleanDirectory ("./component/tools/");
Expand Down
17 changes: 17 additions & 0 deletions tests/Connectivity.Tests.Android/Configuration.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AndroidSdkDirectory>$(HOME)/Library/Developer/Xamarin/android-sdk-macosx</AndroidSdkDirectory>
<JavaSdkDirectory>$(JAVA_HOME)</JavaSdkDirectory>

<AndroidSdkFullPath>$([System.IO.Path]::GetFullPath ('$(AndroidSdkDirectory)'))</AndroidSdkFullPath>

<AdbToolPath Condition=" '$(AdbToolPath)' == '' ">$(AndroidSdkFullPath)\platform-tools</AdbToolPath>
<AdbToolExe Condition=" '$(AdbToolExe)' == '' ">adb</AdbToolExe>

<AvdManagerToolExe Condition=" '$(AvdManagerToolExe)' == '' ">avdmanager</AvdManagerToolExe>
<AndroidToolPath Condition=" '$(AndroidToolPath)' == '' ">$(AndroidSdkFullPath)\tools</AndroidToolPath>
<AndroidToolsBinPath Condition=" '$(AndroidToolsBinPath)' == '' ">$(AndroidToolPath)\bin</AndroidToolsBinPath>
<EmulatorToolPath Condition=" '$(EmulatorToolPath)' == '' ">$(AndroidSdkFullPath)\tools</EmulatorToolPath>
<EmulatorToolExe Condition=" '$(EmulatorToolExe)' == '' ">emulator</EmulatorToolExe>
</PropertyGroup>
</Project>
24 changes: 21 additions & 3 deletions tests/Connectivity.Tests.Android/Connectivity.Tests.Android.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="NUnit.projitems" />
<Import Project="RunUnitTests.target" />
<Import Project="Configuration.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -16,8 +19,9 @@
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v7.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -27,8 +31,9 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64</AndroidSupportedAbis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -37,7 +42,6 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
</PropertyGroup>
<ItemGroup>
Expand All @@ -53,6 +57,7 @@
<Compile Include="TestSample.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestInstrumentation.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
Expand Down Expand Up @@ -85,4 +90,17 @@
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<RunApkTestsDependsOn>
AcquireAndroidTarget;
UndeployTestApks;
DeployTestApks;
RunTestApks;
ReleaseAndroidTarget;
RenameApkTestCases;
</RunApkTestsDependsOn>
</PropertyGroup>
<Target Name="RunUnitTests" DependsOnTargets="$(RunApkTestsDependsOn)">
<Message Text="## Completed unit tests %(TestApk.ResultsPath)" Importance="high" />
</Target>
</Project>
10 changes: 10 additions & 0 deletions tests/Connectivity.Tests.Android/NUnit.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<TestApk Include="$(MyBuildOutputPath)/Connectivity.Tests.Android.Connectivity.Tests.Android-Signed.apk">
<Package>Connectivity.Tests.Android.Connectivity.Tests.Android</Package>
<InstrumentationType>app.tests.TestInstrumentation</InstrumentationType>
<ResultsPath>$(MyBuildOutputPath)/test-results.xml</ResultsPath>
</TestApk>
</ItemGroup>
</Project>
Loading