8ball-media

little pieces from everything

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:

1
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:

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

the resulting xml would look something like:

1
2
3
<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:

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

and you’ll get

1
2
3
4
5
6
<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..

How to port WordPress blog entries to OctoPress .markdown files

This is a quick summary of how to port your existing (selfhosted) WordPress blog to Markdown files for OctoPress using a tool called ExitWP.

# create a temporary folder and cd into it
$ mkdir /tmp/exitwp && cd $_
$ curl -O http://python-distribute.org/distribute_setup.py
$ sudo python distribute_setup.py

After that you can run $ easy_install pip which will produce something like:

$ easy_install pip

Searching for pip
Reading http://pypi.python.org/simple/pip/
Best match: pip 1.5.2
Downloading https://pypi.python.org/packages/source/p/pip/pip-1.5.2.tar.gz#md5=5da30...
Processing pip-1.5.2.tar.gz
Running pip-1.5.2/setup.py -q bdist_egg \
--dist-dir /var/folders/KX/KX5-l3xk+++TI/-Tmp-/easy_install-MB0/pip-1.5.2/egg-dist-tmp-a_J9u5
warning: no files found matching 'pip/cacert.pem'
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
Adding pip 1.5.2 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.6 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Now clone the exitwp repository

$ git@github.com:thomasf/exitwp.git

install the missing dependecies ..

sudo pip install --upgrade -r pip_requirements.txt
# ..
# stripped lots of download related output
# ..
Installing collected packages: html5lib, beautifulsoup4, html2text, six
  Running setup.py install for html5lib
  Running setup.py install for beautifulsoup4
  Running setup.py install for html2text
    Installing html2text script to /usr/local/bin
  Found existing installation: six 1.3.0
    Uninstalling six:
      Successfully uninstalled six
Successfully installed html5lib beautifulsoup4 html2text six
Cleaning up...

And finally:

$ python exitwp.py

After the script has done its work you should find all posts in the build/ directory. Hope that helps and saves you some time.

~ David

Bye WordPress, Welcome Octopress (?!)

I’m (probably) going to leave WordPress in favour of Octopress (in the long run) .

Why? Because i was actually fairly unhappy with WordPress for a while now. Over the years i had to deal with a lot of issues e.g.

  • plug-ins suddenly stop after updates
  • data-loss due mysterious reasons
  • beeing hacked due security issues
  • a White Admin Panel
  • etc.

Switching to Octopress hopefully will solve most of the mentioned reasons. Plus i can play with git and write in Markdown .. ;)

See also: How to move from WordPress to OctoPress

~ davidlinse.github.io

This post was written in Markdown format.
Keywords: Octopress, Wordpress, Markdown, git, White Admin Panel