As the title says - I can't find a way of including a file with a windows store test project. (A standard .NET test project works fine)
Right click on the solution and execute : Add new project -> C# -> Windows Store -> Unit test library (Windows store apps)
You get this boilerplate, to which I have added the DeploymentItem attribute:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
namespace UnitTestLibrary1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
// this does not compile; DeploymentItem attribute not found
[DeploymentItem("wibble.txt")]
public void TestMethod1()
{
}
}
}
So what am I missing? Is it simply not possible to include data in windows store unit tests, or do I need a different approach?
Use @chue-x Build Events, then [TestInitialize] something like:
Now the TestData is available to the app under test.
The way I have been deploying data files is by using a post-build copy. I have my data in my project under a directory called "TestData", which gets copied to the output after a build.
The following lines are set in the "Build Events" tab of the my test project's properties:
A couple of notes:
TestData
, and notAppX\TestData
.DeploymentItem is contained at
Microsoft.VisualStudio.TestTools.UnitTesting
namespace in which you are not having a reference.You have to add a reference to
Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
.