diff --git a/nunit.runner.sln b/nunit.runner.sln
index bbc0643..086adc3 100644
--- a/nunit.runner.sln
+++ b/nunit.runner.sln
@@ -56,8 +56,10 @@ Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\runner\nunit.runner\nunit.runner.projitems*{09bcb5fa-30ad-49af-8034-5670ccb320b5}*SharedItemsImports = 4
src\tests\nunit.runner.tests\nunit.runner.tests.projitems*{17a2b97c-56ea-40b8-8901-5e0728876657}*SharedItemsImports = 4
+ src\tests\nunit.runner.tests\nunit.runner.tests.projitems*{2a198895-edfb-4a82-899e-e7d1d1c592e8}*SharedItemsImports = 4
src\tests\nunit.runner.tests\nunit.runner.tests.projitems*{391ce92c-08f6-4ddf-941c-a8980dcc196e}*SharedItemsImports = 4
src\runner\nunit.runner\nunit.runner.projitems*{3bf3745a-8491-46a9-af66-f8de22accf31}*SharedItemsImports = 4
+ src\runner\nunit.runner\nunit.runner.projitems*{47b8b14f-da28-4188-becb-23c4ee51e0f5}*SharedItemsImports = 4
src\tests\nunit.runner.tests\nunit.runner.tests.projitems*{af293652-baa0-4813-b4f3-2d5a2cdde0b4}*SharedItemsImports = 13
src\tests\nunit.runner.tests\nunit.runner.tests.projitems*{b0040786-1ab0-4fd6-93d2-e5ba330fb4bc}*SharedItemsImports = 4
src\runner\nunit.runner\nunit.runner.projitems*{c9209134-aea3-4c7f-ad74-00d578a6f208}*SharedItemsImports = 13
@@ -213,6 +215,7 @@ Global
{391CE92C-08F6-4DDF-941C-A8980DCC196E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{391CE92C-08F6-4DDF-941C-A8980DCC196E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{391CE92C-08F6-4DDF-941C-A8980DCC196E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {391CE92C-08F6-4DDF-941C-A8980DCC196E}.Debug|iPhone.Deploy.0 = Debug|Any CPU
{391CE92C-08F6-4DDF-941C-A8980DCC196E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{391CE92C-08F6-4DDF-941C-A8980DCC196E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{391CE92C-08F6-4DDF-941C-A8980DCC196E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
diff --git a/src/runner/nunit.runner.Droid/nunit.runner.Droid.csproj b/src/runner/nunit.runner.Droid/nunit.runner.Droid.csproj
index b0a3334..9e10cf3 100644
--- a/src/runner/nunit.runner.Droid/nunit.runner.Droid.csproj
+++ b/src/runner/nunit.runner.Droid/nunit.runner.Droid.csproj
@@ -13,7 +13,7 @@
Resources\Resource.Designer.cs
Off
True
- v6.0
+ v7.0
True
diff --git a/src/runner/nunit.runner/Services/TestOptions.cs b/src/runner/nunit.runner/Services/TestOptions.cs
index 227f12d..5acc5aa 100644
--- a/src/runner/nunit.runner/Services/TestOptions.cs
+++ b/src/runner/nunit.runner/Services/TestOptions.cs
@@ -21,6 +21,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
+using PCLStorage;
+
namespace NUnit.Runner.Services
{
///
@@ -28,6 +30,18 @@ namespace NUnit.Runner.Services
///
public class TestOptions
{
+ const string OutputXmlReportName = "TestResults.xml";
+
+ private string _resultFilePath;
+
+ ///
+ /// Constructor
+ ///
+ public TestOptions()
+ {
+ _resultFilePath = System.IO.Path.Combine(FileSystem.Current.LocalStorage.Path, OutputXmlReportName);
+ }
+
///
/// If True, the tests will run automatically when the app starts
/// otherwise you must run them manually.
@@ -44,5 +58,15 @@ public class TestOptions
/// Creates a NUnit Xml result file on the host file system using PCLStorage library.
///
public bool CreateXmlResultFile { get; set; }
+
+ ///
+ /// File path for the xml result file
+ /// Default is [LocalStorage]/TestResults.xml
+ ///
+ public string ResultFilePath
+ {
+ get { return _resultFilePath; }
+ set { _resultFilePath = value; }
+ }
}
}
diff --git a/src/runner/nunit.runner/Services/XmlFileProcessor.cs b/src/runner/nunit.runner/Services/XmlFileProcessor.cs
index e884d82..3fd4b21 100644
--- a/src/runner/nunit.runner/Services/XmlFileProcessor.cs
+++ b/src/runner/nunit.runner/Services/XmlFileProcessor.cs
@@ -24,12 +24,12 @@
using System;
using System.Diagnostics;
using System.IO;
+using System.Threading;
using System.Threading.Tasks;
-
using NUnit.Framework.Interfaces;
using PCLStorage;
-
+using CreationCollisionOption = PCLStorage.CreationCollisionOption;
using FileAccess = PCLStorage.FileAccess;
namespace NUnit.Runner.Services
@@ -37,9 +37,7 @@ namespace NUnit.Runner.Services
class XmlFileProcessor : TestResultProcessor
{
public XmlFileProcessor(TestOptions options)
- : base(options)
- {
- }
+ : base(options) { }
public override async Task Process(ITestResult testResult)
{
@@ -64,24 +62,57 @@ public override async Task Process(ITestResult testResult)
async Task WriteXmlResultFile(ITestResult testResult)
{
- const string OutputFolderName = "NUnitTestOutput";
- const string OutputXmlReportName = "TestResults.xml";
- var localStorageFolder = FileSystem.Current.LocalStorage;
+ string outputFolderName = Path.GetDirectoryName(Options.ResultFilePath);
+ string outputXmlReportName = Path.GetFileName(Options.ResultFilePath);
- var existResult = await localStorageFolder.CheckExistsAsync(OutputFolderName);
- if (existResult == ExistenceCheckResult.FileExists)
- {
- var existingFile = await localStorageFolder.GetFileAsync(OutputFolderName);
- await existingFile.DeleteAsync();
- }
+ await CreateFolderRecursive(outputFolderName);
- var outputFolder = await localStorageFolder.CreateFolderAsync(OutputFolderName, CreationCollisionOption.OpenIfExists);
- IFile xmlResultFile = await outputFolder.CreateFileAsync(OutputXmlReportName, CreationCollisionOption.ReplaceExisting);
+ IFolder outputFolder =
+ await FileSystem.Current.GetFolderFromPathAsync(outputFolderName, CancellationToken.None);
+
+ IFile xmlResultFile =
+ await outputFolder.CreateFileAsync(outputXmlReportName, CreationCollisionOption.ReplaceExisting);
using (var resultFileStream = new StreamWriter(await xmlResultFile.OpenAsync(FileAccess.ReadAndWrite)))
{
string xmlString = testResult.ToXml(true).OuterXml;
await resultFileStream.WriteAsync(xmlString);
}
}
+
+ ///
+ /// Create a folder from the full folder path if it does not exist
+ /// Throws exception if acess to the path is denied
+ ///
+ ///
+ ///
+ private static async Task CreateFolderRecursive(string folderPath)
+ {
+ string[] segments = new Uri(folderPath).Segments;
+
+ string path = segments[0];
+
+ for (int i = 0; i < segments.Length - 1; i++)
+ {
+ try
+ {
+#if __DROID__ || __IOS__
+ IFolder folder = await FileSystem.Current.GetFolderFromPathAsync(path, CancellationToken.None);
+#else
+ IFolder folder = await FileSystem.Current.GetFolderFromPathAsync(path.Replace('/', '\\'), CancellationToken.None);
+#endif
+ var res = await folder.CheckExistsAsync(segments[i + 1]);
+ if (res != ExistenceCheckResult.FolderExists)
+ {
+ await folder.CreateFolderAsync(segments[i + 1], CreationCollisionOption.OpenIfExists);
+ }
+ }
+ catch (Exception)
+ {
+ // ignore
+ }
+
+ path = Path.Combine(path, segments[i + 1]);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/tests/nunit.runner.tests.Droid/MainActivity.cs b/src/tests/nunit.runner.tests.Droid/MainActivity.cs
index 95e80d2..2ad7ca3 100644
--- a/src/tests/nunit.runner.tests.Droid/MainActivity.cs
+++ b/src/tests/nunit.runner.tests.Droid/MainActivity.cs
@@ -21,6 +21,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
+using System.IO;
using Android.App;
using Android.Content.PM;
using Android.OS;
@@ -56,7 +57,10 @@ protected override void OnCreate(Bundle savedInstanceState)
//TcpWriterParameters = new TcpWriterInfo("192.168.0.108", 13000),
// Creates a NUnit Xml result file on the host file system using PCLStorage library.
- CreateXmlResultFile = true
+ CreateXmlResultFile = true,
+
+ // Choose a diffrent path for the xml result file
+ ResultFilePath = Path.Combine(Environment.ExternalStorageDirectory.Path, Environment.DirectoryDownloads, "Nunit", "Results.xml")
};
LoadApplication(nunit);
diff --git a/src/tests/nunit.runner.tests.Droid/Properties/AndroidManifest.xml b/src/tests/nunit.runner.tests.Droid/Properties/AndroidManifest.xml
index 2818a19..1671a24 100644
--- a/src/tests/nunit.runner.tests.Droid/Properties/AndroidManifest.xml
+++ b/src/tests/nunit.runner.tests.Droid/Properties/AndroidManifest.xml
@@ -1,5 +1,7 @@
-
+
+
+
\ No newline at end of file
diff --git a/src/tests/nunit.runner.tests.Droid/nunit.runner.tests.Droid.csproj b/src/tests/nunit.runner.tests.Droid/nunit.runner.tests.Droid.csproj
index cbfd946..ba96b97 100644
--- a/src/tests/nunit.runner.tests.Droid/nunit.runner.tests.Droid.csproj
+++ b/src/tests/nunit.runner.tests.Droid/nunit.runner.tests.Droid.csproj
@@ -24,7 +24,7 @@
True
- v6.0
+ v7.0
true
diff --git a/src/tests/nunit.runner.tests.iOS/AppDelegate.cs b/src/tests/nunit.runner.tests.iOS/AppDelegate.cs
index d382e77..fb92292 100644
--- a/src/tests/nunit.runner.tests.iOS/AppDelegate.cs
+++ b/src/tests/nunit.runner.tests.iOS/AppDelegate.cs
@@ -21,6 +21,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
+using System;
+using System.IO;
using Foundation;
using NUnit.Runner.Services;
@@ -64,7 +66,10 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)
//TcpWriterParameters = new TcpWriterInfo("192.168.0.108", 13000),
// Creates a NUnit Xml result file on the host file system using PCLStorage library.
- CreateXmlResultFile = false
+ CreateXmlResultFile = true,
+
+ // Choose a diffrent path for the xml result file (ios file share / library directory)
+ ResultFilePath = Path.Combine(NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User)[0].Path, "Results.xml")
};
LoadApplication(nunit);
diff --git a/src/tests/nunit.runner.tests.iOS/Info.plist b/src/tests/nunit.runner.tests.iOS/Info.plist
index f656745..036faa3 100644
--- a/src/tests/nunit.runner.tests.iOS/Info.plist
+++ b/src/tests/nunit.runner.tests.iOS/Info.plist
@@ -1,52 +1,56 @@
-
+
-
- UIDeviceFamily
-
- 1
- 2
-
- UISupportedInterfaceOrientations
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
- UISupportedInterfaceOrientations~ipad
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationPortraitUpsideDown
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
- MinimumOSVersion
- 6.0
- CFBundleDisplayName
- nunit.runner
- CFBundleIdentifier
- com.yourcompany.nunit.runner
- CFBundleVersion
- 1.0
- CFBundleIconFiles
-
- Icon-60@2x
- Icon-60@3x
- Icon-76
- Icon-76@2x
- Default
- Default@2x
- Default-568h@2x
- Default-Portrait
- Default-Portrait@2x
- Icon-Small-40
- Icon-Small-40@2x
- Icon-Small-40@3x
- Icon-Small
- Icon-Small@2x
- Icon-Small@3x
-
- UILaunchStoryboardName
- LaunchScreen
-
+
+ UIDeviceFamily
+
+ 1
+ 2
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ MinimumOSVersion
+ 6.0
+ CFBundleDisplayName
+ nunit.runner
+ CFBundleIdentifier
+ com.yourcompany.nunit.runner
+ CFBundleVersion
+ 1.0
+ CFBundleIconFiles
+
+ Icon-60@2x
+ Icon-60@3x
+ Icon-76
+ Icon-76@2x
+ Default
+ Default@2x
+ Default-568h@2x
+ Default-Portrait
+ Default-Portrait@2x
+ Icon-Small-40
+ Icon-Small-40@2x
+ Icon-Small-40@3x
+ Icon-Small
+ Icon-Small@2x
+ Icon-Small@3x
+
+ UILaunchStoryboardName
+ LaunchScreen
+ CFBundleShortVersionString
+
+ UIFileSharingEnabled
+
+
diff --git a/src/tests/nunit.runner.tests.uwp/MainPage.xaml.cs b/src/tests/nunit.runner.tests.uwp/MainPage.xaml.cs
index ba09009..893b4d5 100644
--- a/src/tests/nunit.runner.tests.uwp/MainPage.xaml.cs
+++ b/src/tests/nunit.runner.tests.uwp/MainPage.xaml.cs
@@ -53,7 +53,11 @@ public MainPage()
//TcpWriterParameters = new TcpWriterInfo("192.168.0.108", 13000),
// Creates a NUnit Xml result file on the host file system using PCLStorage library.
- CreateXmlResultFile = false
+ CreateXmlResultFile = false,
+
+ // Choose a diffrent path for the xml result file
+ // Windows phone 8.1 no permission to create subfolder in Windows.Storage.ApplicationData.Current.LocalFolder
+ // ResultFilePath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.TemporaryFolder.Path, "Nunit", "Results.xml")
};
LoadApplication(nunit);
diff --git a/src/tests/nunit.runner.tests.uwp/Package.appxmanifest b/src/tests/nunit.runner.tests.uwp/Package.appxmanifest
index 994d822..8377044 100644
--- a/src/tests/nunit.runner.tests.uwp/Package.appxmanifest
+++ b/src/tests/nunit.runner.tests.uwp/Package.appxmanifest
@@ -25,5 +25,6 @@
+
\ No newline at end of file