Grunt - Karma 单元测试

Angular.JS 实战教程:深度解析基于TutsPlus的Savage Worlds项目 本文还有配套的精品资源,点击获取 简介:Angular.JS是一个用于构建动态Web应用程序的JavaScript框架,以其数据绑定和依赖注入特性简化前端开发。本教程以"Savage Worlds"项目为案例,深入讲解了如何基于Angular.JS 0.11.0版本进行项目构建、单元测试、开发最佳实践。通过详细探讨核心概念如数据绑定、模块化、控制器、服务、指令,以及如何利用... 阅读详情

 Karma 是 Goolge 开源的一个 Test runner, 可以配合 Grunt 使用。

1. 相关插件介绍

1.1 Karma 的官网

http://karma-runner.github.io/

官网中的文档其实分多钟版本,不同版本的 karma 使用也有所不同,注意页面右上角的版本信息。

1.2 配合 Grunt 的插件 grunt-karma

https://github.com/karma-runner/grunt-karma

1.3 karma 用来启动 chrome 的 karma 插件

https://github.com/karma-runner/karma-chrome-launcher

1.4 jasmine 单元测试插件

https://github.com/karma-runner/karma-jasmine

1.5 单元测试的报表格式

单元测试默认提供了两种输出:'dots', 'progress' ,都比较简单,希望看到测试的详细输出,可以使用 reporter 插件,这里是其中之一:mocha

https://github.com/litixsoft/karma-mocha-reporter

1.6 angularJS 插件

https://github.com/karma-runner/karma-ng-scenario

1.7 requirejs 模块化插件

https://github.com/karma-runner/karma-requirejs

2. 安装插件

2.1 创建 package.json 

使用 npm init 来创建 package.json 项目文件。

PS C:\study\demo> npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
name: (demo) demo
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC) MIT
About to write to C:\study\demo\package.json:

{
  "name": "demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT"
}


Is this ok? (yes) y
PS C:\study\demo>

 安装 Karma

PS C:\study\protocat> npm install karma --save-dev
npm WARN package.json app@1.0.0 No description
npm WARN package.json app@1.0.0 No repository field.
npm WARN package.json app@1.0.0 No README data
npm WARN optional dep failed, continuing fsevents@1.0.0
|


> bufferutil@1.2.1 install C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild


C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  bufferutil.cc
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(214): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc [C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil\build\bufferutil.vcxproj]
     Creating library C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil\build\Release\bufferutil.lib and object C:\study\protocat\node_modules\karma\node_modules\s
  ocket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil\build\Release\bufferutil.expGenerating code
  Finished generating code
  bufferutil.vcxproj -> C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil\build\Release\\bufferutil.node
|


> utf-8-validate@1.2.1 install C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild


C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  validation.cc
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(214): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc [C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate\build\validation.vcxproj]
     Creating library C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate\build\Release\validation.lib and object C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate\build\Release\validation.expGenerating code
  Finished generating code
  validation.vcxproj -> C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate\build\Release\\validation.node
/


> utf-8-validate@1.2.1 install C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild


C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  validation.cc
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(214): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc [C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate\build\validation.vcxproj]
     Creating library C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate\build\Release\validation.lib and object C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate\build\Release\validation.expGenerating code
  Finished generating code
  validation.vcxproj -> C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate\build\Release\\validation.node
|


> bufferutil@1.2.1 install C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild

/
C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  bufferutil.cc
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(214): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc [C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil\build\bufferutil.vcxproj]
     Creating library C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil\build\Release\bufferutil.lib and object C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil\build\Release\bufferutil.exp
  Generating code
  Finished generating code
  bufferutil.vcxproj -> C:\study\protocat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil\build\Release\\bufferutil.node
karma@0.13.10 node_modules\karma
├── di@0.0.1
├── rimraf@2.4.3
├── graceful-fs@4.1.2
├── mime@1.3.4
├── colors@1.1.2
├── bluebird@2.10.1
├── http-proxy@1.11.2 (eventemitter3@1.1.1, requires-port@0.0.1)
├── source-map@0.4.4 (amdefine@1.0.0)
├── useragent@2.1.7 (lru-cache@2.2.4)
├── optimist@0.6.1 (wordwrap@0.0.3, minimist@0.0.10)
├── dom-serialize@2.2.0 (void-elements@1.0.0, custom-event@1.0.0, ent@2.2.0, extend@2.0.1)
├── minimatch@2.0.10 (brace-expansion@1.1.0)
├── glob@5.0.14 (path-is-absolute@1.0.0, inherits@2.0.1, inflight@1.0.4, once@1.3.2)
├── lodash@3.10.1
├── expand-braces@0.1.1 (array-uniq@1.0.2, array-slice@0.2.3, braces@0.1.5)
├── connect@3.4.0 (utils-merge@1.0.0, parseurl@1.3.0, finalhandler@0.4.0, debug@2.2.0)
├── log4js@0.6.27 (async@0.2.10, underscore@1.8.2, semver@4.3.6, readable-stream@1.0.33)
├── core-js@1.1.4
├── memoizee@0.3.9 (next-tick@0.2.2, lru-queue@0.1.0, timers-ext@0.1.0, d@0.1.1, event-emitter@0.3.3, es6-weak-map@0.1.4
, es5-ext@0.10.7)
├── body-parser@1.14.0 (bytes@2.1.0, content-type@1.0.1, depd@1.1.0, on-finished@2.3.0, raw-body@2.1.3, debug@2.2.0, ico
nv-lite@0.4.11, qs@5.1.0, http-errors@1.3.1, type-is@1.6.8)
├── chokidar@1.1.0 (arrify@1.0.0, path-is-absolute@1.0.0, is-glob@2.0.0, async-each@0.1.6, glob-parent@2.0.0, is-binary-
path@1.0.1, readdirp@2.0.0, anymatch@1.3.0)
└── socket.io@1.3.7 (has-binary-data@0.1.3, debug@2.1.0, socket.io-parser@2.2.4, socket.io-adapter@0.3.1, engine.io@1.5.
4, socket.io-client@1.3.7)

安装 grunt-karma 插件。

PS C:\study\demo> npm install grunt-karma --save-dev
npm WARN package.json app@1.0.0 No description
npm WARN package.json app@1.0.0 No repository field.
npm WARN package.json app@1.0.0 No README data
grunt-karma@0.12.1 node_modules\grunt-karma
└── lodash@3.10.1

安装之后,在 node_modules 中实际上有了 grunt, grunt-karma, 以及 karma 三个组件。

继续安装 karma 的插件。

先安装 chrome 的启动器。

PS C:\study\demo> npm install --save-dev karma-chrome-launcher
npm WARN package.json demo@1.0.0 No description
npm WARN package.json demo@1.0.0 No repository field.
npm WARN package.json demo@1.0.0 No README data
karma-chrome-launcher@0.2.0 node_modules\karma-chrome-launcher
├── fs-access@1.0.0 (null-check@1.0.0)
└── which@1.1.2 (is-absolute@0.1.7)

单元测试 jasmine.

PS C:\study\demo> npm install --save-dev karma-jasmine
npm WARN package.json demo@1.0.0 No description
npm WARN package.json demo@1.0.0 No repository field.
npm WARN package.json demo@1.0.0 No README data
npm WARN peerDependencies The peer dependency jasmine-core@* included from karma-jasmine will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
jasmine-core@2.3.4 node_modules\jasmine-core

karma-jasmine@0.3.6 node_modules\karma-jasmine

单元测试的输出报表格式 mocha.

PS C:\study\demo> npm install --save-dev karma-mocha-reporter
npm WARN package.json demo@1.0.0 No description
npm WARN package.json demo@1.0.0 No repository field.
npm WARN package.json demo@1.0.0 No README data
karma-mocha-reporter@1.1.1 node_modules\karma-mocha-reporter
└── chalk@1.1.0 (escape-string-regexp@1.0.3, supports-color@2.0.0, ansi-styles@2.1.0, has-ansi@2.0.0, strip-ansi@3.0.0)

angular 插件

PS C:\study\demo> npm install --save-dev karma-ng-scenario
npm WARN package.json demo@1.0.0 No description
npm WARN package.json demo@1.0.0 No repository field.
npm WARN package.json demo@1.0.0 No README data
karma-ng-scenario@0.1.0 node_modules\karma-ng-scenario

requirejs 插件。

PS C:\study\demo> npm install --save-dev karma-requirejs
npm WARN package.json demo@1.0.0 No description
npm WARN package.json demo@1.0.0 No repository field.
npm WARN package.json demo@1.0.0 No README data
npm WARN peerDependencies The peer dependency requirejs@~2.1 included from karma-requirejs will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
requirejs@2.1.20 node_modules\requirejs

karma-requirejs@0.2.2 node_modules\karma-requirejs

3. 配置

 不用版本的 karma 配置会有所不同,这里使用 v0.13 版。

 karma 的运行配置可以保存在独立的文件中,也可以在 Gruntfile.js 中直接配置,由于 karma 的配置参数较多,建议保存在独立的配置文件中。

这样,我们可以针对不同的测试场景,创建不同的 karma 配置文件,最后通过 grunt 来使用。

karma 配置文件中的 basePath 是一个非常重要的参数,用来表示 karma 配置文件中的其它相对路径所依赖的起点。

如果这是一个对象路径,就会相对于配置文件来定位。

默认是 '', 也就是说配置文件所在的目录就是相对的根目录了。

在 karma 实际运行的时候,这个目录会被自动映射到 /base 之下。

files 中配置可以通过 karma 服务器访问哪些文件,在这里列出的文件,才可以通过 HTTP 访问到。当使用对象方式表示路径的时候,included 表示 karma 是不是需要自动生成一个 script 标记来加载特定的脚本,设置为 false 表示不生成这个标记,而 served 则表示是否可以通过 karma 的网站服务器访问这个文件。

plugins 在 v0.13 中可以不同配置,karma 会自动加载位于 node_modules 中的 karma-* 的 karma 模块。

// Karma configuration
// Generated on Tue Sep 15 2015 12:41:55 GMT+0800 (China Standard Time)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    // if requirejs used, 
    frameworks: ['jasmine', 'requirejs'],


    // list of files / patterns to load in the browser
    files: [
    
      // inclueded, default: true, should the files be included in the browser using <script> tag?
      // use false if you want to load them manually. eg using require.js
      // served, default: true, should the files be served by karma's webserver?
      // watched, default: true, if autowatch is true, all files that have set watched to true will be watched for change
      { pattern: 'src/**/*.*', included: false, served: true },
      { pattern: 'test/**/*_spec.js', included: false, served: true },

      //in version 0.13, the item should be last
      'test-main.js',
    ],


    // list of files to exclude
    exclude: [
        'src/js/main.js'
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['mocha'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // By default, Karma loads all sibling NPM modules which have a name starting with karma-*.
  })
}

在配合 requirejs 的时候,我们还需要一个 main.js 文件对 requirejs 进行配置。

在 requirejs 中也有一个 baseUrl 配置参数,这里一定要考虑刚才karma 的 basePath 进行配置,由于在 karma 的网站中,前面又添加了 /base ,所以,现在 requirejs 的 baseUrl 就会变成 /base/src/js 了。

这样,修改了 baseUrl, 我们其它的模块 Id 就不用变化了。

我们希望能够通过 karma 直接加载测试并执行测试,所以,karma 帮助我们生成了一段脚本,从我们网站中的脚本文件中筛选出测试文件,直接加载执行,脚本通过正则表达式  /(spec|test)\.js$/i 来筛选,可以看到,它直接检查脚本文件名中,以 spec.js 或者 test.js 结尾的脚本文件。找到之后,通过 requirejs 配置中的 deps 提前加载并执行。

var allTestFiles = [];
var TEST_REGEXP = /(spec|test)\.js$/i;

// Get a list of all the test files to include
Object.keys(window.__karma__.files).forEach(function(file) {
  if (TEST_REGEXP.test(file)) {
    // Normalize paths to RequireJS module names.
    // If you require sub-dependencies of test files to be loaded as-is (requiring file extension)
    // then do not normalize the paths
    
    // var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '');
    var normalizedTestModule = file;
    allTestFiles.push(normalizedTestModule);
  }
});

require.config({
  // Karma serves files under /base, which is the basePath from your config file
  baseUrl: '/base/src/js',
    paths:{
      'angular':'lib/angular.min'
    },
  shim:{
    'angular':{
      'exports': 'angular'
    }
  },

  // dynamically load all test files
  deps: allTestFiles,

  // we have to kickoff jasmine, as it is asynchronous
  callback: window.__karma__.start
});

require(['angular', 'controllers/controllers'], function(angular, controller){
  console.log('main.js loaded.');
  console.log( controller);
  
}, function(){
  console.log("load error");
  console.log( arguments);
});

4. 测试的写法

比如,我们有一个模块的定义。

define([], function(){
    
    return function ($scope){

        $scope.name = 'World';

        $scope.phones = [
            {'name': 'Nexus S', 'snippet': 'Fast just got faster with Nexus S.', 'age':1 },
            {'name': 'Motorola XOOM™ with Wi-Fi', 'snippet': 'The Next, Next Generation tablet.', 'age':2 },
            {'name': 'MOTOROLA XOOM™', 'snippet': 'The Next, Next Generation tablet.', 'age':3 }
          ];

          $scope.orderProp = 'age';
    };
})

测试也是一个模块,一定要在测试的依赖项中,将测试所依赖的模块加载进来。

// use define to load dependency block.
define(['controllers/controllers'], function(target) {
    
    // regular jasmine test case
    describe('PhoneCat controllers', function() {
        describe('PhoneListCtrl', function(){

            var scope, ctrl;

            beforeEach(function(){
                scope = {};

                // create controller instance
                ctrl = new target( scope );
            });

            it('should create "Phone" model with 3 phones.', function(){
                expect( scope.phones.length ).toBe( 3 );
            });

            it(' the name of "Phone" model should be "World".', function(){
                expect( scope.name ).toBe('World');
            });

            it('the age of "Phone" model should be "age",', function(){
                expect( scope.orderProp ).toBe( 'age' );
            })
        })
    });
});

 执行之后的输出如下:

PS C:\study\photocat> grunt karma
Running "karma:unit" (karma) task
16 09 2015 14:38:05.540:WARN [karma]: No captured browser, open http://localhost:9876/
16 09 2015 14:38:05.555:INFO [karma]: Karma v0.13.9 server started at http://localhost:9876/
16 09 2015 14:38:05.564:INFO [launcher]: Starting browser Chrome
16 09 2015 14:38:08.382:INFO [Chrome 44.0.2403 (Windows 7 0.0.0)]: Connected on socket IUSWkKhxqSbjN8NzAAAA with id 89877642

Start:
  hello, jasmine.
    √ say hello to jasmine.
  PhoneCat controllers
    PhoneListCtrl
      √ should create "Phone" model with 3 phones.
      √  the name of "Phone" model should be "World".
      √ the age of "Phone" model should be "age",

Finished in 0.013 secs / 0.002 secs

SUMMARY:
√ 4 tests completed

5. 总结

在配合 requirejs 的时候, karma 路径,requirejs 的路径一定要注意,karma 的服务器将我们的服务内容放在了 /base 之下,我们在使用的时候,必须特别注意这一点。

另外,文件名称的大小写问题,在 Windows 系统下大小写不敏感,但是,在 Linux 服务器上,大小写不同将是不同的文件。注意 Karma 服务器中,即使在 Windwos 系统下,也会区分大小写。

在配合 requirejs 时,关键是一定要通过 requirejs 来加载你的模块,而不是直接嵌入带页面中。 

http://requirejs.org/docs/errors.html#mismatch

http://icodeit.org/2013/10/using-karma-as-the-javascript-test-runner/ 

 

电气数据有源配电网实时随机调度数据集 内容概要:本文档由“荔枝科研社”整理,是一份面向电气工程、自动化、控制科学与工程等领域的综合性科研资源合集,聚焦于MATLAB/Simulink仿真技术的应用与实践。资源涵盖永磁同步电机(PMSM)控制、无位置传感器控制、滑模观测器、龙伯格观测器、高频注入法、FOC矢量控制、电机谐波抑制、虚拟同步发电机(VSG)、逆变器稳定性分析、输电线路故障辨识、有源配电网调度、智能优化算法(如A*、RRT*、PSO)、路径规划、机器学习与深度学习(LSTM、CNN、SVM等)、信号处理、电力系统优化等多个核心技术方向。提供大量可复现的Matlab代码与Simulink仿真模型,并包含多篇顶级期刊论文的复现案例,配套详尽说明文档与网盘下载链接,旨在构建系统化、高复用性的科研支持体系,助力技术创新与学术突破。; 适合人群:电气工程、自动化、控制科学与工程、电子信息、计算机、机械电子等相关专业的研究生、科研人员及高年级本科生;特别适用于从事电机驱动控制、智能电网优化、路径规划、信号处理、机器学习预测、无人机与无人船控制等方向研究的专业技术人员。; 使用场景及目标:①支撑科研项目快速搭建仿真平台,验证新算法有效性;②辅助高水平论文复现与改进,提升学术产出效率;③作为课程设计、毕业论文或课题攻关的技术参考;④促进工程原型开发与实际系统优化,实现理论到应用的转化。; 阅读建议:建议结合提供的在线目录系统性浏览,优先选取与自身研究方向契合的内容进行实践;使用过程中应深入阅读附带说明文档,注重代码逻辑理解与参数调优,积极调试仿真模型以掌握核心原理,充分发挥“借力科研”的优势,激发创新思维,提升科研质量与效率。 立即下载

相关推荐

STM32F407用FSMC+DMA驱动LVGL,3.5寸屏流畅度翻倍实战(附CubeMX配置避坑)

本文详细介绍了如何在STM32F407上通过FSMC+DMA驱动LVGL,显著提升3.5寸屏的显示流畅度。从FSMC与DMA的配置原理到LVGL驱动层适配,提供了完整的优化方案和实测数据,帮助开发者解决界面卡顿问题,实现流畅度翻倍的效果。

weixin_30872499的博客 567

如何用 3 步跑通 angular-form-builder:Grunt 构建 + Compass 样式 + Karma 单元测试完整配置教程

**angular-form-builder** 是一个用 CoffeeScript 编写的 AngularJS 表单构建器,支持拖拽方式快速搭建 Bootstrap 表单。本文面向新手,带你用 Grunt 完成构建、用 Compass 编译样式、用 Karma 跑通单元测试,一次配好开发与测试环境。 ## 一、环境准备:1 分钟装好全部依赖 🚀 打开终端进入项目根目录,执行: ```ba

gitblog_00198的博客 686

Chromatix 7实战:从零开始调优ISP模块的完整流程(附常见报错解决方案)

本文提供了高通平台Camera调试工具Chromatix 7的完整实战指南。详细阐述了从环境准备、项目初始化、基础校正(如LSC、BPC)到核心ISP管线(Demosaic、CCM、HDR)及后处理(CAC、ANR)的调优全流程,并附带了常见报错(如“未初始化实例”)的解决方案,旨在帮助工程师建立系统性的调试方法论。

weixin_29290863的博客 655

如何搭建 AngularJS 框架源码开发环境并用 Grunt 完成构建与测试

当你拿到 AngularJS 的源码目录后,需要完成这样一条完整链路:安装构建依赖、用 Grunt 生成可分发的构建产物,再运行单元测试和端到端测试来验证源码修改是否破坏框架行为。本文依据仓库内的 [DEVELOPERS.md](https://link.gitcode.com/i/9bb27ff5c9d6810dca020d0aeed01563)、[package.json](https://l

gitblog_00873的博客 1065

10X Visium空间转录组学入门:从芯片结构到数据分析全流程解析(附避坑指南)

本文全面解析10X Visium空间转录组学技术,从芯片物理结构、探针化学原理到湿实验全流程操作与避坑指南,并详细介绍了从FASTQ数据到空间可视化的核心分析流程。文章旨在帮助科研人员跨越从理论到实操的鸿沟,掌握从样本准备、文库构建到使用Space Ranger和Seurat进行数据分析与可视化的完整路径,为组织生物学研究提供清晰的实践指引。

weixin_29306011的博客 176

Starlink第三代终端与第二代终端的差异分析

SpaceX星链第三代终端实现显著升级,硬件售价维持599美元不变但性能全面提升。相比第二代产品,第三代终端取消自动调节电机改为手动定向,防水防尘等级提升至IP67,天线面积扩大46%,支持235台设备连接(提升87%),下载速度可达1Gbps(提升4倍),延迟降至20ms以下。新增3个千兆接口和WiFi6支持,同时推出199美元单独路由器选项。这些改进使第三代终端在保持价格优势的同时,更好地满足户外、移动和商业场景需求,标志着SpaceX卫星互联网服务从亏损销售转向盈利模式的重要转折。

通信行业老兵、物联网从业者,做一个有趣的普通人。 3050

nodeJS grunt karma+jasmine+require 快速构建前台自动化测试环境搭建

前台自动化测试环境搭建 前言 在Java领域,Apache, Spring, JBoss 三大社区的开源库,包罗万象,但每个库都在其领域中都鹤立鸡群。而Nodejs中各种各样的开源库,却让人眼花缭乱,不知从何下手。 Nodejs领域:Jasmine做单元测试,Karma自动化完成单元测试,Grunt启动Karma统一项目管理,Yeoman最后封装成一个项目原型模板,npm做nodejs的包...

weixin_30709061的博客 173

[Arcgis插件分享]--在线地图、地图配色

插件介绍:MapOnline在线地图插件是一套由北京茗禾科技有限公司研发的基于ArcGIS的插件工具,用户通过注册“数据禾”网站,即可使用MapOnline实现各种在线地图资源的集成加载,以及网站共享资源的免费下载。包括:谷歌地图、谷歌地球(无偏)、高德地图、天地图(无偏)、搜搜地图、必应地图(无偏)、OSM地图(无偏)、Esri影像(无偏),以及自定义切片的加载。⑤在Arcmap操作窗口上方的菜单栏右键,调用「MapOnlinev1.2.4」②双击安装文件夹内的「MapOnline.esriAddIn」

weixin_59101151的博客 5815

Grunt 插件使用汇总

 最近使用了很多 Grunt 插件,这里把使用 Grunt 中涉及的从开发、代码检查、单元测试、E2E 测试,直到发布所涉及的插件,做一个比较完全的汇总。 环境搭建 1. 创建 Web 前端开发环境 2. Grunt 之通配符 3. Grunt 之动态文件路径   grunt 源码分析 1. grunt源码解析:整体运行机制&amp;grunt-cli源码解析   grunt 插...

weixin_34367257的博客 99

别再手动量了!用Python+Open3D给BIM模型做‘CT扫描’,自动揪出施工误差(附完整代码)

本文介绍如何利用Python和Open3D技术实现BIM模型的毫米级施工误差自动检测。通过点云预处理、模型配准和偏差分析,系统能自动生成三维差异热力图和验收报告,显著提升施工质量检测效率。特别适合混凝土结构错位和钢结构安装偏差等常见问题的智能分析。

weixin_29284657的博客 248

告别Keil!用VSCode+PlatformIO玩转STC单片机(附自动下载配置)

本文详细介绍了如何从Keil迁移到VSCode+PlatformIO进行STC单片机开发,包括环境搭建、自动下载配置等实用技巧。通过对比传统IDE与现代工具链的差异,展示了VSCode+PlatformIO在代码编辑体验、跨平台支持和开发效率上的优势,帮助开发者实现更流畅的STC单片机开发流程。

weixin_27252001的博客 467

Angularjs grunt开发相关的有关工具

Nodejs  需要使用npm包  npm install grunt 代码处理工具 bower 依赖管理工具 bower install http-server 在任何地方都可以用浏览器访问 karma 单元测试runner jasmine 单元测试工具 分组:describe(string,function) 一组测试用例 测试用例 it(string,function) 测试用

fishermanmax的博客 273

Parasoft C++Test软件单元测试_操作指南

本文主要为使用C++TEST进行单元测试的流程性操作讲解,后续文章将以专题形式进行详细讲解,以及用一些被测函数作为示例进行实例讲解。

文章主要涉及嵌入式软件开发、测试、项目管理等,欢迎交流,共同进步。 1599

Karma和Jasmine自动化单元测试

[size=small]原文链接:[url]http://blog.fens.me/nodejs-karma-jasmine/[/url] Nodejs领域: Jasmine做单元测试,Karma自动化完成单元测试,Grunt启动Karma统一项目管理,Yeoman最后封装成一个项目原型模板,npm做nodejs的包依赖管理,bower做javascript的包依赖管理。 Java领域:J...

Inner peace 153

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Sequence.js测试与调试:单元测试框架与自动化测试最佳实践

Sequence.js是一个功能强大的响应式CSS动画框架,专门用于创建独特的滑块、演示文稿、横幅广告和其他基于步骤的应用。作为一个成熟的开源项目,它采用了完善的测试策略来确保代码质量和稳定性。本文将深入探讨Sequence.js的测试框架和自动化测试最佳实践,帮助开发者理解如何为CSS动画框架构建可靠的测试体系。 ## 🧪 测试框架配置与架构 Sequence.js使用Karma作为测试运

gitblog_00018的博客 604

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

基于Gruntjs的Web前端基础构建工具

Grunt如今已是前端开发必不可少的工具了,下面我把常用的Grunt插件整理了一下,集成了一个基础性的项目构建工具: package.json: { "name": "demo", "version": "1.0.0", "author":"yushengjie", "description": "基础grunt构建", "devDependencies...

weixin_30821731的博客 90

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

如何用PiBot例行任务(Routines)实现自动化:定时、文件夹触发与待办管理

PiBot 是一款开源、本地优先的桌面 AI 智能体团队应用,支持 macOS、Windows、Linux 和 Android。它的**例行任务(Routines)**功能可以让多个 Bot 按时间、文件变化或连接事件自动干活——比如每周一早上自动写一份行业简报,文件夹里一有新文件就立即整理。本文带你用不到 5 分钟创建一个定时自动化任务,并顺带掌握 PiBot 的待办管理。 [![PiBot

gitblog_01195的博客 323

前端开发、调试、测试工具

前端需要什么样子的开发环境? 1.代码编辑工具 2.断点调试工具 3.版本管理工具 4.代码合并和混淆工具 5.依赖管理工具 6.单元测试工具 7.集成测试工具11款创建前端工具代码编辑工具

神秘的小岛岛 615

基于AngularJS开发撰写测试代码时的框架

本文由Markdown语法编辑而成。1. 前言:在以“测试驱动开发”理念的推动下,测试已经变得越来越重要了。由于之前在做B/S项目的开发过程中前端采用了AngularJS框架。因此这里主要介绍AngularJS在进行测试时采用的框架和基本的测试原理。关于测试的分类,在之前的博文中已经有所介绍。测试一般分为UT, IT和AT。在我所在的项目团队中,开发人员负责撰写UT和IT,测试人员负责撰写AT

inter_peng的专栏 1355

前端与后端的测试工具组合

在Java领域,Apache, Spring, JBoss 三大社区的开源库,包罗万象,但每个库都在其领域中都鹤立鸡群。而Nodejs中各种各样的开源库,却让人眼花缭乱,不知从何下手。 Nodejs领域:  Jasmine做单元测试, Karma自动化完成单元测试, Grunt启动Karma统一项目管理, Yeoman最后封装成一个项目原型模板, npm做nodejs的包依赖管理, ...

sunxboy的专栏 471

Codebrag前端开发实战:AngularJS+Grunt构建响应式代码审查界面

Codebrag 是一款每日代码审查工具(Your daily code review tool),其前端完全由 **AngularJS + Grunt** 技术栈打造,实现了响应式的提交审查界面。本文带你走进 Codebrag 前端开发的实战现场,拆解它的模块化架构、Grunt 自动化构建流程,以及左列表右 Diff 的响应式审查界面是如何一步步搭建起来的,非常适合想了解经典 AngularJS

gitblog_00551的博客 426

前端开发环境

代码编辑工具---sublime/webstorm 断点调试工具---chrome插件Batarang 版本管理工具---git/git小乌龟 代码合并和混淆工具---grunt(nodejs npm安装) 依赖管理工具---bower 单元测试工具/集成测试工具---karma(一款用来跑测试用例的runner,npm安装)+Jasmine(用来编写测试用例,npm安装)/Pr

sanlingwu的博客 330
上一篇: Grunt 之 使用 JavaScript 语法检查工具 jshint
下一篇: gulp - connect
「已注销」
博客等级 码龄6年 0粉丝 456原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值