- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在我的应用程序 (Ext js 5) 中实现 jasmine 以进行单元测试。为此,我创建了应用程序测试文件。
Ext.require('Ext.app.Application');Ext.Loader.setConfig({enabled:true});
Ext.onReady(function() {
var Application = Ext.create('Ext.app.Application', {
name: 'epmct',
appFolder:'app',
launch: function() {
Ext.create('epmct.view.vpp.dashboard.VppDashboardMainPage');
}
});
});
当我通过 specrunner.html(开始单元测试的文件)运行应用程序时出现错误
Uncaught Error: [Ext.Loader] Some requested files failed to load.
我尝试使用 Ext.Loader.setPath('epmct','app'); 设置路径还是不行。
请找到我的specrunner.html文件代码
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.3.2</title>
<link rel="shortcut icon" type="image/png" href="test/jasmine/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="test/jasmine/jasmine.css">
<script type="text/javascript" src="test/jasmine/jasmine.js"></script>
<script type="text/javascript" src="test/jasmine/jasmine-html.js"></script>
<script type="text/javascript" src="test/jasmine/boot.js"></script>
<!-- include Ext Js files and Css... -->
<script src="ext/ext-all.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="app-test.js"></script>
<script type="text/javascript" src="test/spec/DashboardSpec.js"></script>
</head>
<body>
</body>
</html>
最佳答案
我将通过使用 Sencha Cmd 5.、ExtJs 5. 的工作测试来指导您完成快速设置,并希望您仅需 8 个步骤即可使用 Sencha 工作区。
首先使用 Sencha Cmd
创建一个新的工作区。如果您已有工作区,则可以跳过此步骤。
sencha 生成工作区\path\to\the\folder
使用 Sencha Cmd
创建一个新的 ExtJs
应用。
cd\path\to\the\workspace
sencha -sdk\path\to\the\sdk generate app Jasmine Jasmine
然后在 app 文件夹中创建一个名为 app-test
的新文件夹。
lib
文件夹复制到您之前创建的 app-test
文件夹中。index-test.html
并将其放在您的应用程序文件夹中:<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Test</title>
<link rel="shortcut icon" type="image/png" href="app-test/lib/jasmine-2.3.4/jasmine_favicon.png">
<link rel="stylesheet" href="app-test/lib/jasmine-2.3.4/jasmine.css">
<script src="app-test/lib/jasmine-2.3.4/jasmine.js"></script>
<script src="app-test/lib/jasmine-2.3.4/jasmine-html.js"></script>
<script src="app-test/lib/jasmine-2.3.4/boot.js"></script>
<!-- include source files here... -->
<script src="../ext/build/ext-all-debug.js"></script>
<!-- include spec files here... -->
<script src="app-test.js"></script>
</head>
<body>
<div id="test"></div>
</body>
</html>
app-test.js
并将其放在您的应用程序文件夹中:Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: 'Jasmine',
extend: 'Jasmine.Application',
autoCreateViewport: false
});
describe('Jasmine.view.main.Main', function() {
//reusable scoped variable
var mainView = null;
// setup / teardown
beforeEach(function() {
// create a fresh main view for every test to avoid test pollution
mainView = Ext.create('Jasmine.view.main.Main'/*, {
renderTo : 'test' //see index-test.html to see where this is defined
}*/);
});
afterEach(function() {
// destroy the main view after every test so we don't pollute the environment
mainView.destroy();
});
it('should inherit from Ext.container.Container', function() {
expect(mainView.isXType('container')).toEqual(true);
});
it('should be configured as a border layout', function() {
expect(mainView.getLayout().type).toEqual('border');
});
});
额外资源:
http://www.ladysign-apps.com/developer/setup-jasmine-tdd-with-for-ext-js/
https://www.sencha.com/blog/automating-unit-tests/
https://github.com/SenchaProSvcs/UnitTestDemo
http://docs.sencha.com/extjs/4.2.0/#!/guide/testing
http://docs.sencha.com/extjs/4.2.0/#!/guide/testing_controllers
https://jasmine.github.io/2.3/introduction.html
关于javascript - 当我尝试使用 jasmine 进行测试时,应用程序文件夹未加载到 Ext.appliation 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31923991/
我使用 File > Settings > JavaScript > Libraries 在 Webstorm 8.0.4 中设置 Jasmine 集成。我添加了 karma-jasmine带有我的
假设我有 spyOn($cookieStore,'get').and.returnValue('abc'); 对于我的用例来说,这太笼统了。任何时候我们打电话 $cookieStore.get('so
我正在阅读有关 Jasmine 测试的教程,它建议您应该使用标准 Jasmine 目录树结构(这似乎与 RSpec 目录树结构有关)。我用谷歌搜索了一个小时,找不到任何有关此标准目录树的信息。 考虑到
问题 如何使用Jasmine插件通过Jasmine运行Karma时更新所使用的karma-jasmine的版本? 仅当Jasmine插件集成了较新版本的karma-jasmine时,才会更新Jasmi
我想在每个规范执行后获得测试的通过或失败状态: var passed = jasmine.getEnv().currentSpec.results().passed(); if (!pas
我有一个与 Karma 一起运行的 Jasmine 测试: describe('When a logged in user chooses Rent and Payment PIN is enable
在我的新手理解中,Jasmine 提供了以下语法: describe('FooBar', function(){ it('should blah-blah', function(){ ex
我认为我通过编写这样的 Jasmine 模拟取得了很好的进展。但我无法修复这个错误。 spyOn 方法实际上是如何工作的?事实上这种方法似乎被广泛使用。 2.0 有什么变化 describe('Tes
有大量文档展示了如何将匹配器添加到 Jasmine 规范(例如 here )。 有人找到了向整个环境添加匹配器的方法吗?我想创建一组有用的匹配器,供任何和所有测试调用,而无需在我的规范中复制粘贴。 目
我正在尝试查找所有现有 Jasmine 期望匹配器(例如“toContain”等)的列表... 哪里可以找到这个?我搜索了一段时间,但找不到像 api 这样的东西。 Jasmine 网站也没有任何类型
我熟悉 python 单元测试测试,如果断言失败,该测试将被标记为“失败”,并继续进行其他测试。另一方面,即使其中一个失败, Jasmine 也会继续完成所有期望。如何让 Jasmine 在第一个期望
工具:Protractor 3.3.0、Jasmine 2.4.1、Selenium Standalone Server。 我有一个测试套件,里面有大量的 spec.js 文件,每个文件都包含我的应用
Jasmine 中是否有与 console.log 类似的方法?如果我想注销我 mock 的 $controller 或服务的值,有没有办法做到这一点? 最佳答案 您应该只使用 console.log
我已经通过运行 npm install jasmine -g 全局安装了 jasmine。 运行 jasmine -v 给我 jasmine v2.5.0 jasmine-core v2.5.0 然后
我有gulp-jasmine-phantom正在运行,但我得到 ReferenceError: Tictactoe is not defined 。我感觉我犯了一些根本性的错误。 我的文件结构: gu
我已经创建了一个 JavaScript 项目,需要使用 Jasmine 进行单元测试。我遵循了以下步骤: 1. npm install jasmine --save-dev - 从项目根目录 2.现在
我正在为我的应用程序使用 Yeoman+Angular Generator,我一直在努力与 Jasmine 相处!这就是我卡住的地方。我希望能够在 Jasmine 测试中使用 jQuery 选择器。我
it('should for something', function check(done) { browser.sleep(2000); $('.csTx').isPresent().th
Javascript 编码有点新,所以请耐心等待。 我阅读了以下链接 jasmine with jscoverage automated testing 但是,由于我没有 Ruby 项目,因此它似乎不
在Jasmine headless (headless)Webkit中运行测试时,我遇到了一个简单的TypeError: 'undefined' is not an object失败。但是没有提示在哪
我是一名优秀的程序员,十分优秀!