Framework

 

A

 

For

 

 

 

of

Automated 

Testing

JavaScript

Web Apps.

little tool support

to assist JavaScript programmers to test their codes.

Selendium

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
   withCapabilities(webdriver.Capabilities.chrome()).
   build();

driver.get('http://www.google.com');
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.name('btnG')).click();
driver.wait(function() {
 return driver.getTitle().then(function(title) {
   return title === 'webdriver - Google Search';
 });
}, 1000);

driver.quit();

Watir

require 'watir-webdriver'
b = Watir::Browser.new
b.goto 'bit.ly/watir-webdriver-demo'
b.text_field(:id => 'entry_0').set 'your name'
b.select_list(:id => 'entry_1').select 'Ruby'
b.select_list(:id => 'entry_1').selected? 'Ruby'
b.button(:name => 'submit').click
b.text.include? 'Thank you'

JS is Event Driven

Def.

 

+ Event parameter map

+ Form state map

+ Browser state

Event

 

+ URL

+ Server/Browser State

+ Sequence of Events

Test Input

Execution Model

Request -> Load HTML -> DOM -> Execute TL JS

Algo.

\varepsilon

Execution Unit

\rho

Prioritaizer

g

Input Generator

Prioritizer Func.

c = (u, S, s_1 ... s_n)

the set of event handlers that are executed when the i’th event is triggered during the execution of c.

e_i

Default Strategy

P_0(c) = 1

Coverage Strategy

P_1(c) = 1 - cov(e_1) \times ... \times cov(e_n)

Read/Write Strategy

P_2(c) = \dfrac{|(written(e_1) \cup ... \cup writter(e_{n-1}))\cap read(e_n)|+1}{|read(e_n)+1|}

Input Generator

Default Strategy

G_0

Reasonable event parameters

Dynamically. Collected Strategy

G_1

maintains

\varepsilon \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ const(e)

 

  • Does the events feedback-directed algorithm achieve significantly better coverage than initial?

Research Questions

 

  • What level of code coverage is achieved by each of the test generation algorithms with the same number of tests?

Research Questions

 

  • How quickly does each of the feedback-directed algorithms converge on the maximal coverage that it will achieve?

Research Questions

 

  • How many HTML validity errors and runtime errors are detected by the different algorithms?

Research Questions

Experimental Methodology

+ Minified Javascript

+ Dynamically generated code (eval or <script>)

+ Dynamically generated code by Server

Performance

100 test inputs
at most 2 minutes.

 

PC running Linux
3.2Ghz CPU and 2GB of memory

JS Testing

By amir

JS Testing

  • 936