Skip to content

Dancer::Test thoughts

Stefan Hornburg (Racke) edited this page Apr 3, 2014 · 2 revisions

These are my thoughts so far. Some of my comments are probably due to lack of knowledge on my part and some are maybe just plain silly/unreasonable but here we go...

Note from racke: We replaced Dancer2::Test in Dancer2 with Plack::Test and I expect the same will happen in Dancer1 one as well.

Dancer trashes appdir/views on cart create

in Dancer.pm we have

sub _init_script_dir {
...
    # in bin/ or public/ or t/ we need to go one level upper to find the appdir
    $LAYOUT_PRE_DANCER_1_2 = 0
      if ($script_dirs[$#script_dirs - 1] eq 'bin')
      or ($script_dirs[$#script_dirs - 1] eq 'public')
      or ($script_dirs[$#script_dirs - 1] eq 't');

Somehow when shop_cart first gets called the above code path gets hit and so if our tests live directly below 't' then appdir gets reset and following tests fail since views has also changed and so our views cannot be found.

Must use config.yml for DP::Auth::Extensible

Trying to set config for this plugin inside the test script fails - the config just gets ignored. Gets very confusing when you think you have no_default_pages: 1 but you get the default pages after all.

Module loading order and app setup

Getting everything ordered correctly to setup your test app before running the first test is critical. One silly change and your test script blows up.

Can I see an example that avoids these problems?

See the DPIC6 route test commit to see the end result.