Skip to content

Running integration tests interactively

Mika Vilpas edited this page May 6, 2016 · 3 revisions

Intro

This is a tutorial on a way to run the integration tests, a way that provides the developer the best of both worlds:

  • the joy of interactive development that Emacs in general gives
  • repeatability and reliability that written tests offer

Let's get started

The lispy package provides many enhancements for lisp editing. It embraces the structural nature of lisp by encouraging you to edit it structurally.

  • install lispy - or if you like Evil you can install evil-lispy instead.

  • open a test file, such as formatting-test.el

  • split your frame into two windows. In Evil you can do this with C-w C-v.

  • now, this is where this gets interesting (drum roll)

  • move point to this position ($ on the second line):

  (before-each
    $(ot--open-the-minimal-project-source-file "KeystrokeTest.cs"))

  (it "formats on pressing semicolon"
    (ot--buffer-contents-and-point-at-$
     "public class KeystrokeTest"
     "{"
     "    public KeystrokeTest()"
     "    {"
     "   var    i  =1$"
     "    }")

    (omnisharp-format-on-keystroke ";")
    (ot--buffer-should-contain
     "public class KeystrokeTest"
     "{"
     "    public KeystrokeTest()"
     "    {"
     "        var i = 1;"
     "    }"))
  • this position is called the special position in lispy. When point is on this position, lispy commands will be performed instead of writing characters.
  • Note that if you are using evil-lispy, you will always have to explicitly activate lispy. You can do this by e.g. pressing ( or ) in normal mode or ) in insert mode - this will jump to the previous/next parenthesis and read the following commands as lispy commands.
  • now press p (lispy-eval-other-window). This will run the expression at point in the context of the split window.
  • after this you should see the split window opening the desired file. Now you can continue to run expressions in the test buffer by pressing p when your point is on the desired expressions.

Summary

To recap the workflow:

  • whenever you develop your code, write tests that set up your test buffer and call whatever you need to
  • split your frame into two windows
  • using lispy, run the tests expression by expression with p in the newly split window

Tips

  • if you have more than one monitor, you should open another Emacs frame with C-x 5 2. Have this frame display the *omnisharp-debug* log as well as the OmniServer process buffer. This way you can also read what goes in and out the server process while developing.
Clone this wiki locally