1.1.1222 • Published 2 years ago

testful v1.1.1222

Weekly downloads
121
License
-
Repository
github
Last release
2 years ago

Testful

testful is a node.js test framework for restful service test. Just to give the expect http response, and the http call options. It will test for you, compare the expect result & actual result.

What you need to do is to construct the test data for http request.

installation

With npm, just do:

npm install -g testful

or clone this project on github:

git clone https://github.com/codelint/testful.git

To run the sample test case: just do:

./do_sample_test

examples

You just give the case data like below:

// file[./sample/get_post_timeout.js] is a sample
// ---------------------------- test cases defines --------------------------- //
//input & expect is require
var Cases = {
  "test1 title": {
    result: true / false        //after test will fill by tester
    input:{
      host: "localhost",      //optional
      port: 5555,             //optional
      method: "POST"/"GET",
      headers:{},
      path:"/url/to/call/api?param1=1&param2=2"
      body:{}                 //for post
    },
    expect:{
      statusCode: 200,
      headers:{},
      body:{}
    },
    actual: {                   //after test will fill by tester
      statusCode: 200,
      headers: {},
      body: {}
    },
    error: {                    //if error occur during testing, tester will fill this field
    }
    before: Function(next, title, case),          //optional
    after: Function(next, title, case),           //optional
    setup: Function(next, title, case),           //optional
    teardown: Function(next, title, case)         //optional
  },
  "test2 title": { ... }
}

// file[./sample/server.context.json] is a sample
// ------- test server's context ------------ //
var context = {
  //if give the server, tester will start server auto;
  //if not give, you must confirm the host:port you give is startup
  server: nodejs-server,
  host: 'localhost',
  port: 5555,
  timeout: 500,
  encoding: 'utf8'
}
// init : function(next, cases),
// close : function(next, cases)

contact author

nick: DGMan
email: codelint@foxmail.com
1.0.1222

2 years ago

1.1.1222

2 years ago

1.0.1464

10 years ago

1.0.1463

10 years ago

1.0.1462

10 years ago

1.0.1461

10 years ago

1.0.1460

10 years ago

1.0.1459

10 years ago

1.0.1409

10 years ago

1.0.1457

10 years ago

0.1.965

10 years ago

0.1.964

10 years ago

0.1.937

10 years ago

0.1.384

12 years ago

0.1.378

12 years ago

0.1.377

12 years ago

0.1.376

12 years ago

0.1.375

12 years ago

0.1.374

12 years ago

0.1.337

12 years ago

0.1.335

12 years ago

0.1.327

12 years ago

0.1.321

12 years ago

0.1.320

12 years ago

0.1.10

12 years ago

0.1.319

12 years ago

0.1.8

12 years ago

0.1.7

12 years ago

0.1.6

12 years ago

0.1.5

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago