Jasmine in a separate test project

前端 未结 3 624
悲哀的现实
悲哀的现实 2021-02-01 05:26

Is it practical/possible to separate jasmine tests into a separate visual studio project?

I am just getting started with angular, and am trying to write my tests befor

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-01 05:51

    Traditionally, I've always kept unit tests in separate assemblies.

    I've read both sides of the argument and prefer not to ship code that isn't production code, or to have additional deployment steps to remove tests from production code.

    In order to reference javascript in my Web.Client.Tests assembly, for example, I use a post-build event to copy the files into the test project. For this I use robocopy - it looks something like this:

    robocopy "$(ProjectDir)app" "$(SolutionDir)Tests\Presentation\Web.Client.Tests\app" /E /COPY:D /IS 
    
    robocopy "$(ProjectDir)Scripts" "$(SolutionDir)Tests\Presentation\Web.Client.Tests\Scripts" /E /COPY:D /IS
    
    if errorlevel 1 GOTO :eof 
    

    The main con with this approach is that you have to build the project each time, like you'd have to with your C# code, to update the test project before running the tests.

提交回复
热议问题