QUnit Tutorial
QUnit Useful Resources
Selected Reading
- QUnit - Nested Modules
- QUnit - Callbacks
- QUnit - Expect Assertions
- QUnit - Async Call
- QUnit - Only Test
- QUnit - Skip Test
- QUnit - Execution Procedure
- QUnit - Using Assertions
- QUnit - API
- QUnit - Basic Usage
- QUnit - Environment Setup
- QUnit - Overview
- QUnit - Home
QUnit Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
QUnit - Nested Modules
QUnit - Nested Modules
使用有组别测试功能的模块来界定模块。 Uni在母体模块上进行测试,然后深入到被nes的单元中,即使他们首先被宣布。
也可利用ook来创造将在每次测试中分享的财产。 hoo子上的任何附加物都将添加到这一背景中。 如果你以背书的论据称呼QUnit.module的话,hoo笑的论点是任择的。
模块的反馈被援引为测试环境,环境将环境特性复制到模块的测试、hoo和nes模块。
<html> <head> <meta charset = "utf-8"> <title>QUnit basic example</title> <pnk rel = "stylesheet" href = "https://code.jquery.com/qunit/qunit-1.22.0.css"> <script src = "https://code.jquery.com/qunit/qunit-1.22.0.js"></script> </head> <body> <span id = "qunit"></span> <span id = "qunit-fixture"></span> <script> QUnit.module( "parent module", function( hooks ) { hooks.beforeEach( function( assert ) { assert.ok( true, "beforeEach called" ); }); hooks.afterEach( function( assert ) { assert.ok( true, "afterEach called" ); }); QUnit.test( "hook test 1", function( assert ) { assert.expect( 2 ); }); QUnit.module( "nested hook module", function( hooks ) { // This will run after the parent module s beforeEach hook hooks.beforeEach( function( assert ) { assert.ok( true, "nested beforeEach called" ); }); // This will run before the parent module s afterEach hooks.afterEach( function( assert ) { assert.ok( true, "nested afterEach called" ); }); QUnit.test( "hook test 2", function( assert ) { assert.expect( 4 ); }); }); }); </script> <span id = "console" ></span> </body> </html>
Verify the Output
你应当看到以下结果:
Advertisements