Testes unitarios em java script

0 respostas
fmeyer

Sim eles sao possiveis …

Referencia:
http://wiki.script.aculo.us/scriptaculous/show/UnitTesting

apresentacao

Exemplo

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Page title</title>
  <script src="path/to/prototype.js" type="text/javascript"></script>
  <script src="path/to/util.js" type="text/javascript"></script>
  <script src="path/to/unittest.js" type="text/javascript"></script>
  <!-- other JavaScript includes -->
  <link rel="stylesheet" href="path/to/test.css" type="text/css" />
</head>
<body>

<!-- Log output -->
<div id="testlog"> </div>

<!-- here go any elements you do the testing on -->

<!-- Tests -->
<script type="text/javascript" language="javascript">
// <![CDATA[
// new Test.Unit.Runner instance
new Test.Unit.Runner({
  // optional setup function, run before each individual test case
  setup: function() { with(this) {
    // code
  }},
  // optional teardown function, run after each individual test case
  teardown: function() { with(this) {
    // code
  }},
  // test cases follow, each method which starts 
  // with "test" is considered a test case
  testATest: function() { with(this) {
    // code
  }},
  testAnotherTest: function() { with(this) {
    // code
  }}
}, { options });
// ]]>
</script>
</body>
</html>
Criado 19 de dezembro de 2006
Respostas 0
Participantes 1