Permalink
Browse files

added Readme.md and commented code

  • Loading branch information...
1 parent c12ef92 commit d90dcf3c198569ffca47c40e54740633f5c81521 zyndiecate committed Dec 5, 2011
Showing with 100 additions and 5 deletions.
  1. +41 −0 Readme.md
  2. +3 −0 examples/custom_assertions.js
  3. +3 −0 examples/custom_processors.js
  4. +46 −4 examples/example_test.js
  5. +7 −1 examples/method_processor.js
View
@@ -0,0 +1,41 @@
+# Broke
+
+ Broke is just a layer for vowsjs, to make your tests
+ a little bit nicer. So you can define your own process
+ phases and custom assertions, that make your tests smarter.
+ Configure your test cases and decide how often a test
+ have to repeat, when a test have to time out and so on.
+
+ Further there is a custom processor given to test requests
+ easily.
+
+
+
+## Installation:
+
+ Install broke locally to get "var broke = require('broke')"
+ to work. Install it globally to make the test runner
+ working and you can do "broke example_test.js --spec".
+
+ $ npm install broke
+ $ sudo npm install broke -g
+
+
+
+## Usage:
+
+ For better documentation and usage look for the examples.
+ They are well commented.
+
+
+
+## Tests:
+
+ $ vows node_modules/broke/tests/cases/* --spec
+
+
+
+## Questions and suggestions?
+
+ Send me a message on github.
+
@@ -2,6 +2,9 @@
*
* Custom Assertions module.
*
+ * Custom assertions have to return an object that contains
+ * the tested assertion name as key and a function that tests
+ * the parameters you have injected into "this.callback()".
*/
/*
@@ -2,6 +2,9 @@
*
* Custom Processors module.
*
+ * Custom processors in their easiest form, just provides
+ * a function that is called in the scope of a vows topic.
+ * Look for examples/method_processor.js.
*/
/*
View
@@ -1,15 +1,33 @@
+/*
+ *
+ * Example Test module.
+ *
+ */
+/*
+ * Node dependencies.
+ */
var broke = require('../libs/broke')
, assert = require('assert');
+/*
+ * Test suite config including custom processors and
+ * custom assertions.
+ */
var config = {
processors: require('./custom_processors.js'),
assertions: require('./custom_assertions.js'),
};
+/*
+ * Create a new test suite.
+ */
broke
.test('dummy test suite')
+ /*
+ * Start phases are just batches you can call as you like.
+ */
.start({
'init the test suite': {
process: {
@@ -26,23 +44,39 @@ broke
}
})
+ /*
+ * Batches can be configured and do what you want.
+ */
.batch({
'test your code': {
config: {
- repeats: 5,
- delay: 500,
- calmDown: 500,
- timeout: 2000
+ repeats: 5, // Repeats the test case 5 times.
+ delay: 500, // Process the test case after 500 ms.
+ calmDown: 500, // Assert the test case after 500 ms.
+ timeout: 2000 // End the test with an error after 2000 ms.
},
process: {
+ /*
+ * Process requests. To do that you have to inject the request
+ * processor into the run(module, [config]) method.
+ */
request: {method: 'GET', url: 'http://google.com', options: {port: 80}}
},
assert: {
+ /*
+ * Assert requests. To do that you have to inject the statusCode
+ * assertion into the run(module, [config]) method.
+ */
statusCode: 301
}
}
+
+ // Define more test cases to execute them asynchronousely.
})
+ /*
+ * Stop phases are just batches you can call as you like.
+ */
.stop({
'tear down the test suite': {
process: {
@@ -59,6 +93,14 @@ broke
}
})
+/*
+ * Run a test suite and export it.
+ *
+ * @param object module, a reference to the current module.
+ * @param object config, the config including processors and assertions.
+ *
+ * @return object, instance of initialized test suite.
+ */
.run(module, config);
@@ -6,7 +6,13 @@
/*
* Just call the process function with the scope of a
- * vows topic.
+ * vows topic. So you can do something like that:
+ *
+ * process: {
+ * method: function() {
+ * // use vows "this.callback"
+ * }
+ * }
*
* @param object vowsContext, the vows context to add the topic.
* @param object brokeContext, a given broke context.

0 comments on commit d90dcf3

Please sign in to comment.