How to add a meta data file like YAML to your Xamarin Test Package

Currently when it runs in the clod. Xamarin is just uploading the test dlls and not our yaml file that contains important test data like servers etc that app can connect to.

As a result at run time it cant find the yaml file. We set the yaml file in the project to copy to output directory and when run locally it is in the directory. Cloud runs don't have the file as it is not uploaded.

[[[ XTC-Output-Path: '/Volumes/Data/xamarin/workspaces/pipeline20160404-52311-1vtmhx1/workspace/tmp/TestRun-20160404-181915-5028' ]]]

Tests run: 3, Errors: 2, Failures: 0, Inconclusive: 0, Time: 222.1862579 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

Errors and Failures:
1) Test Error : ###.XTCTests.LogonTests(Android).LogonLocalServerTest
System.TypeInitializationException : The type initializer for 'Tableau.XTCTests.CoreSettings' threw an exception.
----> System.IO.FileNotFoundException : Could not find file "/Volumes/Data/xamarin/workspaces/pipeline20160404-52311-1vtmhx1/workspace/Settings.yml".
at #####.XTCTests.LogonTests.LogonLocalServerTest () <0x59ea8f8 + 0x000e7> in :0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x7cd070 + 0x00093> in :0
--FileNotFoundException
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) <0x71b070 + 0x006cf> in :0

Posts

  • Glenn.WilsonGlenn.Wilson USXamarin Team Xamurai

    @Craig_Horsfield There are two basic approaches.

    Embedded File
    You can include the file as an embedded resource in your UITest project.

    This link is to some Xamarin Code that shows how to access embedded resources from your C# code at runtime. It is more or less generic C# and can work in iOS, Android, and in your UITest methods:
    http://developer.xamarin.com/content/EmbeddedResources/

    Which takes you to (if you browse the code):
    https://github.com/xamarin/mobile-samples/tree/master/EmbeddedResources

    Where the main code to use is at:
    https://github.com/xamarin/mobile-samples/blob/master/EmbeddedResources/SharedLib/ResourceLoader.cs

    (you can un comment the convenience methods in that file)

    Or, if you prefer an MS version, you can see:
    https://support.microsoft.com/en-us/kb/319292

    You can use this locally in your UITest and get it working using the embedded resource approach and then run it in the test cloud.

    First, include the file(s) as an embedded resource to your UITest project;
    Then, at run time, access the file as an embedded resource (the links above show some ways to do that

    --data option
    The above approach works when submitting from the IDE or from the command line.

    There is also a --data option that can be used on the command line. That may be a better choice in some circumstances but can only be used from the command line.

    --data <file-or-directory>

    • Uploads file or directory along with assemblies. (Can be used multiple times)
  • Craig_HorsfieldCraig_Horsfield USMember ✭✭

    Both worked well. Thanks

  • Kent.GreenKent.Green USXamarin Team Xamurai
    edited January 2018

    I've just discovered a slight difference of how the argument is set up for AppCenter/Test compared to Xamarin Test Cloud.

    • Xamarin Test Cloud: --data <file-or-directory>
    • AppCenter/Test: --include <file-or-directory>
Sign In or Register to comment.