Jasmine 在一个单独的测试项目中 [英] Jasmine in a separate test project

查看:17
本文介绍了Jasmine 在一个单独的测试项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将 jasmine 测试分离到单独的 Visual Studio 项目中是否可行/可行?

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

我刚刚开始使用 Angular,并试图在开始实际的 Angular 实现之前编写我的测试.我将使用 Chutzpah 测试运行程序Visual Studio 2012 中编写我的项目,请参阅此 视频.目前,我正在尝试弄清楚如何组织我的文件夹结构.我知道 angular-seed 和 yeoman,但它们不适合启动 .net 项目.

I am just getting started with angular, and am trying to write my tests before I start on the actual angular implementation. I will be writing my project in Visual Studio 2012 with the Chutzpah test runner, see this video. Currently, I am trying to figure out how to organize my folder structure. I know about angular-seed and yeoman, but those are ill suited to starting a .net project.

我假设由于 Visual Studio 中的单元测试通常被分离到一个单独的测试项目中,按照惯例,jasmine 测试也应该这样做.

I am assuming that since unit tests in Visual Studio are usually separated into a separate test project, by convention, the jasmine tests should, too.

但是,对于 java 脚本,没有可引用的项目 dll,因此我认为将测试分离到不同的项目中需要大量的复制和粘贴.

However, for java script, there are no project dlls to reference, so separating the tests out into a different project would require a lot of copy and pasting, I think.

推荐答案

您无需复制/粘贴即可完成此操作.在您的 Jasmine 测试中,您可以添加一个 ///<reference 评论,该评论发布到您的源文件(或包含它们的目录).例如给定这种结构

You can do this with no copy/pasting. In your Jasmine tests you can add a /// <reference comment which posts to your source files (or the directory containing them). For example given this sturcture

/ProjectA/脚本

/ProjectA /scripts

code1.js
code2.js

/TestProjectB test1.js

/TestProjectB test1.js

您可以在 test1.js 文件的顶部添加此行以引用您的所有代码文件:

You can add this line at the top of your test1.js file to reference all your code files:

/// <reference path="../scripts" />

这篇关于Jasmine 在一个单独的测试项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆