Atom的'spec'文件如何工作? [英] How do Atom's 'spec' files work?

查看:285
本文介绍了Atom的'spec'文件如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Atom制作一个包,Travis CI一直告诉我我的生成失败。

更新:我创建了一个空规范文件, 。

I'm making a package for Atom, and Travis CI keeps telling me my build failed.
Update: I created a blank spec file and now my builds are passing.

您可以在这里查看我的包裹: https://travis-ci.org/frayment/language-jazz

You can see my package here: 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包并且他们似乎是基于CoffeeScript,但我不能理解它们包含什么。关于这个主题没有太多的文档,所以:

I went looking around at Atom packages on GitHub for 'spec' files and they seem to be CoffeeScript based, but I can't understand what on earth they contain. There isn't much documentation on the subject, so:

什么是'spec'文件,我放在什么?

帮助非常感谢。

推荐答案

./ spec 目录应包含一个或多个 Jasmine规格为您正在开发的 Atom包,例如,这个规范取自Atom文档:

The ./spec directory should contain one or more Jasmine Specifications for the Atom Package you are developing, for example, this spec is taken from the Atom documentation:

describe "when a test is written", ->
  it "has some expectations that should pass", ->
    expect("apples").toEqual("apples")
    expect("oranges").not.toEqual("apples")

开源软件面临的最大挑战之一是当大量个人贡献者提供代码时保持质量,一个解决方案是提供高水平的测试覆盖率

One of the biggest challenges with Open Source software is maintaining quality when a large number of individual contributors are providing code, one solution to this is providing a high level of test coverage:


像编程的大多数方面一样,测试需要周到。 TDD是一个非常有用的,但肯定不是足够的工具,以帮助你得到良好的测试。如果你仔细测试,我期望在80年代或90年代的覆盖百分比。我会怀疑任何类似的100% - 它会闻到一个人写测试,使覆盖数字快乐,但不考虑他们在做什么。

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 。您的规范应该运用代码的关键领域,以便在提交提出请求到您的主分支。

In Atom's case, all of the specifications are added to the ./spec folder and must end with -spec.coffee, so for example if you were creating a package named awesome and your code sat within /awesome.coffee then you spec would be ./spec/awesome.coffee. Your spec should exercise the key areas of your code to give you confidence when committing pull requests to your master branch.

我有一个夫妻套装在Atom.io上,并且这两个测试都包含它们,欢迎您使用这些作为Jasmine 1.3测试如何编写以支持您的软件包的功能的具体示例。同样,Atom.io上的大多数包也有一组测试,您可以借助它们构建自己的测试套件。

I have a couple of packages on Atom.io and both of these have tests included with them, you are welcome to use these as concrete examples of how Jasmine 1.3 tests can be written to support the functionality of your packages. Equally the majority of packages on Atom.io also have a set of tests that you can draw upon to build your own test suite.

这篇关于Atom的'spec'文件如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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