Chutzpah running Jasmine in TFS 2012 can't find referenced file under test

帅比萌擦擦* 提交于 2019-12-05 14:13:33

Solution I can live with for now

For both the jasmine test files and the files under test I added "Always copy" in properties as per the Chutzpah documentation. I didn't realise that the files under test were actually being copied to the builds bin folder along with the jasmine test files. So on the build server I ended up with the following struacture

bin
    scripts
        app
            * application js files
        specs
            * jasmine test files

In my jasmine test file I add two references:

  • The first to the Visual Studio directory sturcture of the file to be tested
  • The second to the build bin folder structure

Hack 1

I can get it to work by adding another reference to my jasmine test file which uses the structure of the build directory and not the solution directory structure but again this is open to error as the path may be typed in incorrectly.

The second reference below will allow the tests to run in both VS Test Explorer and TFS Build

/// <reference path="../../../../../../App.Web/scripts/app/home/datecontrol.js" />
/// <reference path="../../../../../_PublishedWebsites\App.Web/scripts/app/home/datecontrol.js" />

Hack 2

By adding an xcopy command to the post-build build event of the project I can copy the files to be tested into the same location as the jasmine test files.

This is most likely caused by the fact that Team Build separates the Sources and Binaries folders and enforces a different output structure in the Binaries folder as well. This means your files are not in the place you expect them to be.

To ensure the test runner can always find your references you must use the "Add as Link" option in Visual Studio and set their build action to "Copy Always" so that they're copied to the test directory upon test execution.

Plus, you might need to enable "Deployment" in the Test configuration in your Build Definition, as outlined here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!