本文介绍了Atom'spec'文件未测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我上一个问题开始,,我想尝试但是现在,无论多少 describe it ,我已经成功注册了由Atom注册的'spec'文件>



我使用命令 apm test ,而我得到的是:

  [655:0527/083825:WARNING:resource_bundle.cc(305)] locale_file_path .empty()for locale英语
[655:0527/083825:ERROR:file_io.cc(30)] read:expected 40,observed 0
[659:0527/083825:WARNING:resource_bundle.cc (305)] locale_file_path.empty()用于语言环境
[655:0527/083828:INFO:CONSOLE(52)]窗口加载时间:2420ms,source:file:///Applications/Atom.app /Contents/Resources/app.asar/static/index.js(52)


完成于0.023秒
0测试,0断言,0失败,0跳过

测试通过

根据spec文件判断



我的spec文件如下...(语法)荧光笔套装)

 描述Jazz grammar, - > 
grammar = null

beforeEach - >
waitsForPromise - >
atom.packages.activatePackage(language-jazz)

runs - >
grammar = atom.grammars.grammarForScopeName(source.jazz)

它解析语法, - >
expect(语法).toBeDefined()
expect(grammar.scopeName).toBesource.jazz

ittokenises keywords, - >
tokens = grammar.tokenizeLines('func')

expect(tokens [0] [0] .value).toBe'func'
expect(tokens [0] 0] .scopes).toEqual ['source.jazz','storage.type.jazz']

it标记函数参数中的注释, - >
tokens = grammar.tokenizeLines('module test(arg1,;; arg2)')

expect(tokens [0] [0] .value).toBe'module'
expect(tokens [0] [1] .scopes).toEqual ['source.jazz','storage.type.jazz']
expect(tokens [0] source.jazz','comment.line.jazz']

我的文件结构如下: / p>


  • language-jazz


    • 语法
      $ b b

      • jazz.cson


    • snippets


      • language-jazz.cson

      / li>
    • spec


      • jazz-spec.coffee


    • package.json

    • 其他GitHub Travis CI stuff。



解决方案

问题是你的规范中你的测试的缩进和结构,记住在CoffeeScript空白是重要的和运行块用于封装的代码块不分组 it 语句。



所以规范应该是:

 描述Jazz语法, - > 
grammar = null

beforeEach - >
waitsForPromise - >
atom.packages.activatePackage(language-jazz)

grammar = atom.grammars.grammarForScopeName(source.jazz)

it语法, - >
expect(语法).toBeDefined()
expect(grammar.scopeName).toBesource.jazz

ittokenises keywords, - >
tokens = grammar.tokenizeLines('func')

expect(tokens [0] [0] .value).toBe'func'
expect(tokens [0] 0] .scopes).toEqual ['source.jazz','storage.type.jazz']

it标记函数参数中的注释, - >
tokens = grammar.tokenizeLines('module test(arg1,;; arg2)')

expect(tokens [0] [0] .value).toBe'module'
expect(tokens [0] [1] .scopes).toEqual ['source.jazz','storage.type.jazz']
expect(tokens [0] source.jazz','comment.line.jazz']

显示为三个失败的测试,因为我已经实施你的语法。


Following up from my previous question, here, I am trying to get 'spec' files registered by Atom, which I have succeeded in, however now, no matter how many describe and it's I do, it doesn't do anything when I test it.

I use the command, apm test, and all I get is:

[655:0527/083825:WARNING:resource_bundle.cc(305)]  locale_file_path.empty() for locale English
[655:0527/083825:ERROR:file_io.cc(30)] read: expected 40, observed 0
[659:0527/083825:WARNING:resource_bundle.cc(305)] locale_file_path.empty() for locale English
[655:0527/083828:INFO:CONSOLE(52)] "Window load time: 2420ms", source: file:///Applications/Atom.app/Contents/Resources/app.asar/static/index.js (52)


Finished in 0.023 seconds
0 tests, 0 assertions, 0 failures, 0 skipped

Tests passed

Judging by the spec file (which is definitely being registered, as it complains when it doesn't exist), I should have 3 tests run.

My spec file is as follows... (Syntax Highlighter package)

describe "Jazz grammar", ->
  grammar = null

  beforeEach ->
    waitsForPromise ->
      atom.packages.activatePackage("language-jazz")

    runs ->
      grammar = atom.grammars.grammarForScopeName("source.jazz")

    it "parses the grammar", ->
        expect(grammar).toBeDefined()
        expect(grammar.scopeName).toBe "source.jazz"

    it "tokenises keywords", ->
        tokens = grammar.tokenizeLines('func')

        expect(tokens[0][0].value).toBe 'func'
        expect(tokens[0][0].scopes).toEqual ['source.jazz', 'storage.type.jazz']

    it "tokenizes comments inside function parameters", ->
        tokens = grammar.tokenizeLines('module test(arg1, ;; arg2)')

        expect(tokens[0][0].value).toBe 'module'
        expect(tokens[0][0].scopes).toEqual ['source.jazz', 'storage.type.jazz']
        expect(tokens[0][1].scopes).toEqual ['source.jazz', 'comment.line.jazz']

My file structure is as follows:

  • language-jazz
    • grammars
      • jazz.cson
    • snippets
      • language-jazz.cson
    • spec
      • jazz-spec.coffee
    • package.json
    • Other GitHub and Travis CI stuff.

解决方案

The problem is the indentation and structure of your tests in your spec, bear in mind that in CoffeeScript whitespace is significant and the run blocks are used to encapsulate blocks of the code not to group it statements.

So the spec should be:

describe "Jazz grammar", ->
  grammar = null

  beforeEach ->
    waitsForPromise ->
      atom.packages.activatePackage("language-jazz")

  grammar = atom.grammars.grammarForScopeName("source.jazz")

  it "parses the grammar", ->
    expect(grammar).toBeDefined()
    expect(grammar.scopeName).toBe "source.jazz"

  it "tokenises keywords", ->
    tokens = grammar.tokenizeLines('func')

    expect(tokens[0][0].value).toBe 'func'
    expect(tokens[0][0].scopes).toEqual ['source.jazz', 'storage.type.jazz']

  it "tokenizes comments inside function parameters", ->
    tokens = grammar.tokenizeLines('module test(arg1, ;; arg2)')

    expect(tokens[0][0].value).toBe 'module'
    expect(tokens[0][0].scopes).toEqual ['source.jazz', 'storage.type.jazz']
    expect(tokens[0][1].scopes).toEqual ['source.jazz', 'comment.line.jazz']

I've tested this locally and it shows up as three failing tests, as I have implemented your grammar.

这篇关于Atom'spec'文件未测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 18:42