qunit testing slider

29
PAYMENT FORM Unit Test Using Qunit Tess Hsu 1

Upload: yating-chatiron

Post on 19-Feb-2017

205 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Qunit testing slider

Tess Hsu 1

PAYMENT FORMUnit Test

Using Qunit

Page 2: Qunit testing slider

Tess Hsu 2

Introduce Qunit

Usage

Automation with Grunt watch

Page 3: Qunit testing slider

Tess Hsu 3

INTRODUCE

QUNITWhy use Qunit?

Page 4: Qunit testing slider

Tess Hsu 4

WHY QUNIT?1.You could testing in your local without server, environment setting

2. Special for jQuery, JQuery UI, Jquery Mobile

3. Not only support testing in browser, also support testing in Rhino or node.js

Page 5: Qunit testing slider

Tess Hsu 5

USAGEVery easy!!

Page 6: Qunit testing slider

Tess Hsu 6

USAGEBasic file require1. Qunit.js2. Qunit.cssThat’s it!!!!!!!!!!!

Page 7: Qunit testing slider

Tess Hsu 7

USAGEThat’s build one Test file in your web package !!

Page 8: Qunit testing slider

Tess Hsu 8

USAGEYour web package├ src // plugin source, project files, etc (could be diff for you) ├ tests // work on here│ ├ script │ │ ├ qunit-2.0.1.js // qunit library js │ │ ├ formTesing.js //your testing file name│ │ └ otherTesting.js // if you need other testing in different model │ ├ formTest.html // our QUnit test specification │ └ css // your qunit css │ ├ qunit-2.0.1.css // qunit library css │ ├ Gruntfile.js // add qunit task ├ package.json // to install qunit package └ ...

Page 9: Qunit testing slider

Tess Hsu 9

USAGEStart first your formTesting.html

1. Head: Insert quint css2. Body : Insert first qunit id class to have this first demonstrate qunit test page3. Body: insert what element you want to test4. Finally, got to include js file you need to call for those testing method

Page 10: Qunit testing slider

Tess Hsu 10

USAGEPut what you like to test

Page 11: Qunit testing slider

Tess Hsu 11

USAGEDon’t forgot to include your testing js files, including qunit js library

Page 12: Qunit testing slider

Tess Hsu 12

USAGEThen let’s start most simple testing js file, here I called my testing file: fromTesting. js1. Put your testing module name, this is also could be in different testing module ex: QUnit.module( "Field validator" ) or Qunit. Module(“API tesing”) etc2. Start your testing functionality code, for example

Page 13: Qunit testing slider

Tess Hsu 13

USAGEMethod to useThere’s reference method like ok(), notOk() || equal(), notEqual() etc

http://api.qunitjs.com/category/assert/

Page 14: Qunit testing slider

Tess Hsu 14

USAGEMethod to useFor example here, tesing input field has id: firstname

Page 15: Qunit testing slider

Tess Hsu 15

USAGEOutput will be like this:

Page 16: Qunit testing slider

Tess Hsu 16

USAGEFor special case, you could add some rule directly to testing function

Page 17: Qunit testing slider

Tess Hsu 17

USAGEOutput will be like this:

Page 18: Qunit testing slider

Tess Hsu 18

USAGEExample over view of your all testing list

Page 19: Qunit testing slider

Tess Hsu 19

USAGEIf you have fail, here is output looks like:

Page 20: Qunit testing slider

Tess Hsu 20

AUTOMATION WITH GRUNT WATCH

Page 21: Qunit testing slider

Tess Hsu 21

AUTOMATION WITH GRUNT WATCH

3 step:1. Install qunit2. Add in grunt initConfig, task to run3. Add in watch.js for auto run

Page 22: Qunit testing slider

Tess Hsu 22

AUTOMATION WITH GRUNT WATCH1. Install qunit

Add "grunt-contrib-qunit": "^1.2.0", (version could be differ) in Package.json

Page 23: Qunit testing slider

Tess Hsu 23

AUTOMATION WITH GRUNT WATCH~$ npm install

Page 24: Qunit testing slider

Tess Hsu 24

AUTOMATION WITH GRUNT WATCH

In Gruntfile.js: add config, loadTask, then registerTask

Page 25: Qunit testing slider

Tess Hsu 25

AUTOMATION WITH GRUNT WATCH

In watch.js: this is for watch to find where to excute test js file

Page 26: Qunit testing slider

Tess Hsu 26

AUTOMATION WITH GRUNT WATCH

You are done!! Run grunt watch

~$ grunt watch

Page 27: Qunit testing slider

Tess Hsu 27

AUTOMATION WITH GRUNT WATCH

If Success

Page 28: Qunit testing slider

Tess Hsu 28

AUTOMATION WITH GRUNT WATCH

If has fails

Page 29: Qunit testing slider

Tess Hsu 29

FIN, THANK YOU!!