Atom 的 'spec' 文件如何工作?
How do Atom's 'spec' files work?
我正在为 Atom 制作一个包,Travis CI 一直告诉我构建失败。
更新:我创建了一个空白规范文件,现在我的构建通过了。
你可以在这里看到我的包裹:https://travis-ci.org/frayment/language-jazz
控制台告诉我:
sh: line 105: ./spec: No such file or directory
Missing spec folder! Please consider adding a test suite in
我查看了 GitHub 上的 Atom 包以查找 'spec' 文件,它们似乎是基于 CoffeeScript 的,但我不明白它们到底包含什么。关于这个主题的文档不多,所以:
什么是 'spec' 文件,我应该在里面放什么?
非常感谢您的帮助。
./spec
目录应该包含一个或多个Jasmine Specifications for the Atom Package you are developing,例如,这个规范取自Atom文档:
describe "when a test is written", ->
it "has some expectations that should pass", ->
expect("apples").toEqual("apples")
expect("oranges").not.toEqual("apples")
开源软件面临的最大挑战之一是在大量个人贡献者提供代码时保持质量,一个解决方案是提供 high level of test coverage:
Like most aspects of programming, testing requires thoughtfulness. TDD is a very useful, but certainly not sufficient, tool to help you get good tests. If you are testing thoughtfully and well, I would expect a coverage percentage in the upper 80s or 90s. I would be suspicious of anything like 100% - it would smell of someone writing tests to make the coverage numbers happy, but not thinking about what they are doing.
在 Atom 的情况下,所有规范都添加到 ./spec
文件夹中,并且必须以 -spec.coffee
结尾,例如,如果您正在创建一个名为 awesome
的包并且您代码位于 /awesome.coffee
内,那么您指定的代码将是 ./spec/awesome.coffee
。你的规范应该练习你代码的关键区域,让你在提交 pull requests 到你的 master 分支时有信心。
我在 Atom.io 上有一个 couple of packages,这两个都包含测试,欢迎您使用这些作为具体示例,说明如何编写 Jasmine 1.3 测试以支持该功能你的包裹。同样,Atom.io 上的大多数软件包也有一组测试,您可以利用这些测试来构建自己的测试套件。
我正在为 Atom 制作一个包,Travis CI 一直告诉我构建失败。
更新:我创建了一个空白规范文件,现在我的构建通过了。
你可以在这里看到我的包裹:https://travis-ci.org/frayment/language-jazz
控制台告诉我:
sh: line 105: ./spec: No such file or directory
Missing spec folder! Please consider adding a test suite in
我查看了 GitHub 上的 Atom 包以查找 'spec' 文件,它们似乎是基于 CoffeeScript 的,但我不明白它们到底包含什么。关于这个主题的文档不多,所以:
什么是 'spec' 文件,我应该在里面放什么?
非常感谢您的帮助。
./spec
目录应该包含一个或多个Jasmine Specifications for the Atom Package you are developing,例如,这个规范取自Atom文档:
describe "when a test is written", ->
it "has some expectations that should pass", ->
expect("apples").toEqual("apples")
expect("oranges").not.toEqual("apples")
开源软件面临的最大挑战之一是在大量个人贡献者提供代码时保持质量,一个解决方案是提供 high level of test coverage:
Like most aspects of programming, testing requires thoughtfulness. TDD is a very useful, but certainly not sufficient, tool to help you get good tests. If you are testing thoughtfully and well, I would expect a coverage percentage in the upper 80s or 90s. I would be suspicious of anything like 100% - it would smell of someone writing tests to make the coverage numbers happy, but not thinking about what they are doing.
在 Atom 的情况下,所有规范都添加到 ./spec
文件夹中,并且必须以 -spec.coffee
结尾,例如,如果您正在创建一个名为 awesome
的包并且您代码位于 /awesome.coffee
内,那么您指定的代码将是 ./spec/awesome.coffee
。你的规范应该练习你代码的关键区域,让你在提交 pull requests 到你的 master 分支时有信心。
我在 Atom.io 上有一个 couple of packages,这两个都包含测试,欢迎您使用这些作为具体示例,说明如何编写 Jasmine 1.3 测试以支持该功能你的包裹。同样,Atom.io 上的大多数软件包也有一组测试,您可以利用这些测试来构建自己的测试套件。