English 中文(简体)
QUnit - Execution Procedure
  • 时间:2024-03-22 10:01:30

QUnit - Execution Procedure


Previous Page Next Page  

本章解释了在QUnit实施方法的程序,其中规定首先采用这种方法,然后采用这种方法。 下面是“QUnit”测试APIC方法的执行程序,有一例。

<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( "Module A", {
            beforeEach: function( assert ) {
               assert.ok( true, "before test case" );
            }, afterEach: function( assert ) {
               assert.ok( true, "after test case" );
            }
         });
         
         QUnit.test( "test case 1", function( assert ) {
            assert.ok( true, "Module A: in test case 1" );
         });
         
         QUnit.test( "test case 2", function( assert ) {
            assert.ok( true, "Module A: in test case 2" );
         });
		 		 
         QUnit.module( "Module B" );		
         QUnit.test( "test case 1", function( assert ) {
            assert.ok( true, "Module B: in test case 1" );
         });
         
         QUnit.test( "test case 2", function( assert ) {
            assert.ok( true, "Module B: in test case 2" );
         });		 
      </script>
   </body>
</html>

Verify the Output

你应当看到以下结果: