QUnit - Yalnızca Test

Bazen kodumuz hazır değildir ve çalıştırılırsa bu yöntemi / kodu test etmek için yazılmış test senaryosu başarısız olur. QUnit.onlybu konuda yardımcı olur. Yalnızca yöntem kullanılarak yazılan bir test yöntemi yürütülürken diğer testler çalışmayacaktır. Yalnızca birden fazla yöntem belirtilirse, yalnızca birincisi yürütülür. Sadece yöntem eylemde görelim.

<html>
   <head>
      <meta charset = "utf-8">
      <title>QUnit basic example</title>
      <link 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>
      <div id = "qunit"></div>
      <div id = "qunit-fixture"></div> 
      <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.only( "test case 2", function( assert ) {
            assert.ok( true, "Module A: in test case 2" );
         });
		      
         QUnit.test( "test case 3", function( assert ) {
            assert.ok( true, "Module A: in test case 3" );
         });
		 
         QUnit.test( "test case 4", function( assert ) {
            assert.ok( true, "Module A: in test case 4" );
         });	 
      </script>
   </body>
</html>

Çıkışı Doğrulayın

Aşağıdaki sonucu görmelisiniz -