CasperJS – fail test with custom testcase-name in xml report

It took some time, but my PR to CasperJS has landed. Now you can fail a test with a custom value for a testcase node’s name property like:

casper.test.fail('A custom message', {name: 'custom name'});


tl;dr


When using the --xunit=/path/to/report.xml casperjs is using the message as property for the name of the testcase node in xml report. This means if you fail a test like:

casper.fail('A really long and expressive message');


the resulting xml would look something like:

<testcase classname="a-custom-test-case-name" name="A really long and expressive message" time="0.023">
  <failure type="fail">A really long and expressive message</failure>
</testcase>


Imagine you want to capture and provide an stacktrace from a jsp page as message..


Here comes the optional argument FTW. As stated above, pass in a arbitrary object with a name property like:

var stacktrace = casper.fictional_method_to_capture_stacktrace();
casper.test.fail(stacktrace, {name: 'stacktrace'});


and you’ll get

<testcase classname="a-custom-test-case-name" name="stacktrace" time="0.023">
  <failure type="fail">Exception in thread "main" java.lang.NullPointerException
    at Test.test(Test.java:6)
    at Test.main(Test.java:10)
  </failure>
</testcase>


Much better..

Posted in javascript | Tagged , | 1 Comment

‘grunt-complexity-updater’ for nodejs

grunt-complexity-updater is a a little grunt-task that want to help you in multiple ways during development. It utilizes grunt-complexity to:

  • break your build if maintainability drops below a given threshold and will
  • auto-update the overall-maintainability with lowest detected maintainability in .complexityrc


This free’s you from the need to manually update a thresholds file and will (hopefully) help you to semi-automatic increase the maintainability of your project in the long run.

Here is actually all you need.

$ npm install grunt-complexity-updater

// in your Gruntfile.js
grunt.initConfig({
  complexity: {
    generic: {
      src: ['lib/*.js'],
      options: grunt.file.readJSON('.complexityrc')
    }
  }
});

grunt.loadNpmTasks('grunt-complexity-updater');

// a little shortcut
grunt.registerTask('test', ['update-grunt-complexity-values'])


Create a .complexityrc file and make it look like:

{
  "maintainability":      1,    // initial value, will be updated on next run
  "broadcast":            true, // make grunt-complexity broadcasting data

  // following settings are up to you
  //
  "breakOnErrors":        true|false,
  "errorsOnly":           true|false,
  "cyclomatic":           0,
  "halstead":             0,
  "hideComplexFunctions": false
}


That’s it.


I hope grunt-complexity will report more metrics in the future which i would really like to implement.


You can find “grunt-complexity-updater” either on npm or on github. Feel free to try and let me know what you think or file an(y) issues here


~david

Posted in javascript, nodejs | Tagged , , | Leave a comment

Word wise navigation in iTerm2

Navigating in the terminal can be quite cumbersome but there are “Escape Sequences” to the rescue.

Open the preference pane of “iTerm2″ (or just hit CMD + ,) and go to the “Profiles” menu. There you should find a tab called “Keys”.

Create a new Key-Binding and assign “⌥ + ←” (Option + Left) as the Shortcut. Now choose “Send Escape Sequence” as “Action” and set “Esc + b” as value.

Now you should have a ‘jump word wise backward’ cursor..

Do the same for the “⌥ + →” (Option + Right) and use “Esc + f” as sequences which allows you to jump word wise forward.

Update: What about deleting word-wise ? Just define “⌥ + DELETE” (Option + Delete) and choose “Send Hex Codes” with 17 as value and you’re done.

Feel free to share or leave a comment and now:
happy navigating and deleting.. ;)

~david

Posted in howto | Tagged , , , | Leave a comment

picks of the month #1

picks of the month (#1)

You want to stay in your editor even while committing, merging or diff‘n your git-based project ? Then you really should have a look at this awesome looking plugin for Sublime Text.

  • sublimerge – A diff and merge tool for Sublime Text 2/3

You’re interessed in the performance (and other metrics) of your front-end ? Check out the phantomas node module. It is evolving heavily and the number of contributors in growing steadily. It provides you with a nice graphical overview including longest request, biggest requested data and a lot of other metrics. Go ahead and give it a try.

  • phantomas – Measure Front-End-Performance with NodeJS

Want to preview .json or README files with the QuickLook in Finder in OSX ? Give [QLStephen] a try.. A quick download’n extract to ~/Library/Quicklook folder and you’re done!

Pretty cool, aye ?

Posted in javascript, picks of the month | Tagged , , , , | Leave a comment

picks of the week (#47)

Not much this week ..

picks of the week (#47)

Posted in pick of the week, stuff | Tagged , , | Leave a comment