From 3dbca261e2a0fc392ab0cc2e63c9d0c2d948bcf1 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 31 Oct 2014 00:42:26 -0400 Subject: Implement proper unit tests --- .travis.yml | 15 +++++++++++++++ README.org | 2 -- tests.el | 25 ++++++++++++------------- 3 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6b7d7ea --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +# Stolen from capitaomorte/yasnippet +language: emacs + +env: + - "EMACS=emacs24" + +install: + - if [ "$EMACS" = "emacs24" ]; then + sudo add-apt-repository -y ppa:cassou/emacs && + sudo apt-get -qq update && + sudo apt-get -qq -f install && + sudo apt-get -qq install emacs24-nox; + fi + +script: emacs -batch -l ert -l tests.el -f ert-run-tests-batch-and-exit diff --git a/README.org b/README.org index 46ab6ca..ba9e51c 100644 --- a/README.org +++ b/README.org @@ -18,8 +18,6 @@ The best way to contribute right now is via discussion. Open an issue describing a feature you'd like (That isn't already listed) or a package you think would come in handy. ** Wishlist -- Proper unit tests :: Nothing too in-depth -- just a start using 'the - right way' would be /very/ nice - Automatic testing system (usable with Travis CI) :: Along with unit-testing, it would be best to have this done in Travis CI so that pull requests can be examined before merge. diff --git a/tests.el b/tests.el index bf9b94e..24caedb 100644 --- a/tests.el +++ b/tests.el @@ -1,3 +1,10 @@ +(defun -stack--nuke () + (interactive) + (mapatoms + (lambda (symbol) + (if (string-prefix-p "stack-" (symbol-name symbol)) + (unintern symbol))))) + ;;; Tests (add-to-list 'load-path ".") @@ -5,17 +12,9 @@ (require 'stack-core) (require 'stack-question) -(setq - stack-tmp (stack-question-get-questions 'emacs) - stack-tmp-2 (stack-question-get-questions 'emacs 2)) +(ert-deftest test-question-retrieve () + (should (stack-question-get-questions 'emacs))) -(prog1 nil - (stack-message "%S" stack-tmp) - (stack-message "%S" stack-tmp-2)) - -(defun -stack--nuke () - (interactive) - (mapatoms - (lambda (symbol) - (if (string-prefix-p "stack-" (symbol-name symbol)) - (unintern symbol))))) +(ert-deftest test-bad-request () + (should-error + (stack-core-make-request "questions" '(())))) -- cgit v1.2.3