โดย Ik Kat » 29/06/2017 2:59 pm
QUnit เป็นเครื่องมือในการกำหนดค่าสถานะ , การทดสอบ , การแสดงผล ที่พัฒนาขึ้นด้วย
JavaScript ซึ่งรองรับทั้ง jQuery,
jQuery UI และ
jQuery Mobile
- MT19 29-6-60(31).png (6.57 KiB) Viewed 1090 times
A minimal QUnit test setup :
โค้ด: เลือกทั้งหมด
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>QUnit Example</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.3.3.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-2.3.3.js"></script>
<script src="tests.js"></script>
</body>
</html>
The contents of tests.js :
โค้ด: เลือกทั้งหมด
QUnit.test( "hello test", function( assert ) {
assert.ok( 1 == "1", "Passed!" );
});
Install QUnit globally so you can use the CLI :
Create test files in a test directory and then simply run :
And you should see some output like :
โค้ด: เลือกทั้งหมด
TAP version 13
ok 1 Module > Test #1
ok 2 Module > Test #2
1..2
# pass 2
# skip 0
# todo 0
# fail 0
สนับสนุน Browsers เช่นเดียวกับ jQuery 3.x.
ประโยชน์ QUnit : สามารถทดสอบการทำงานได้หลายฟังก์ชั่นพร้อมกัน
- MT19 29-6-60(32).png (17.64 KiB) Viewed 1090 times
สามารถดาวน์โหลดได้ที่ :
http://qunitjs.com/
[b]QUnit[/b] เป็นเครื่องมือในการกำหนดค่าสถานะ , การทดสอบ , การแสดงผล ที่พัฒนาขึ้นด้วย [url=https://www.mindphp.com/%E0%B8%84%E0%B8%B9%E0%B9%88%E0%B8%A1%E0%B8%B7%E0%B8%AD/73-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3/2187-java-javascript-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3.html]JavaScript[/url] ซึ่งรองรับทั้ง jQuery,
[url=https://www.mindphp.com/forums/viewtopic.php?f=78&t=40769]jQuery UI[/url] และ [url=https://www.mindphp.com/forums/viewtopic.php?f=78&t=40733&p=98932&hilit=jQuery+Mobile#p98932]jQuery Mobile[/url]
[attachment=1]MT19 29-6-60(31).png[/attachment]
[b]A minimal QUnit test setup :[/b]
[code]<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>QUnit Example</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.3.3.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-2.3.3.js"></script>
<script src="tests.js"></script>
</body>
</html>[/code]
[b]The contents of tests.js :[/b]
[code]QUnit.test( "hello test", function( assert ) {
assert.ok( 1 == "1", "Passed!" );
});[/code]
[b]Install QUnit globally so you can use the CLI :[/b]
[code]
$ npm install -g qunitjs[/code]
[b]Create test files in a test directory and then simply run :[/b]
[code]$ qunit[/code]
[b]And you should see some output like :[/b]
[code]TAP version 13
ok 1 Module > Test #1
ok 2 Module > Test #2
1..2
# pass 2
# skip 0
# todo 0
# fail 0[/code]
[code]$ qunit 'tests/*-test.js'[/code]
[code]$ qunit --help[/code]
สนับสนุน Browsers เช่นเดียวกับ jQuery 3.x.
[b]ประโยชน์ QUnit :[/b] สามารถทดสอบการทำงานได้หลายฟังก์ชั่นพร้อมกัน
[attachment=0]MT19 29-6-60(32).png[/attachment]
สามารถดาวน์โหลดได้ที่ : [url]http://qunitjs.com/[/url]