Friday 15 February 2013

TFS build using testing files

TFS build using testing files

Desired result

I want to run test that are using test files on server.
I am targeting VS and TFS 2012

Solution

My test solution layout.


Add all your files into folder which is part of your solution.
Set property all files you need for tests to content and copy always.
This will ensure that files are always the latest ones.




Now create test class

    [TestClass]
    [DeploymentItem(@"TestData", @"TestData")]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Assert.IsTrue(File.Exists(@"TestData\TextFile1.txt"));
        }
    }

and test result

You need to use in, out directory for Deployment Item, this will copy only existing item from your solution. I have not managed to create only empty directory.

Check if your directory has been created in location: ClassLibrary1.Tests\bin\Debug.

You can read up about DeploymentItem


No comments:

Post a Comment