开发者

How to automate unit testing in Squeak

I am checking Squeak homework assignments submitted by my students. I have written an SUnit test case with a bunch of tests and now I want to run these on all submissions.

I would like to somehow automate - whether from inside Squeak or with shell scripts - the process of loading a student submission, running the test case on it, and saving the results in some format.

I've ran into two major problems:

  1. I don't know how to interact with Squeak from the shell - e.g. how can I load some image and then run a set of specific commands there? I looking for examples online but couldn't even manage to load an image.
  2. I tried to keep everything inside Squeak but it turns out loading a source file which contains existing classes does not only overrides the existing classes (which is okay) but also makes all previous references to these classes become invalid, making me unable to re-run the tests.

More information: all students have submitted a source file (not an image file) with one or more classes inside, with all submissions containing at least 开发者_如何学Goone class with a specific name (say, "SubmissionClass").


You might want to check out the build scripts that Yanni Chiu originally posted in the Pharo mailing list and that I extended and published on GitHub http://github.com/renggli/builder.

The code probably provides too much functionality for your case, but it presents all the necessary steps that are also required in your task:

  • http://github.com/renggli/builder/blob/master/build.sh (Line 111) shows how to start a Pharo (or Squeak) VM from the shell.
  • The variable $OUTPUT_SCRIPT contains the full path to a script that loads code and runs tests. This is a concatenation (line 105-108) of one or more of the scripts in http://github.com/renggli/builder/tree/master/scripts/.
  • For example, testrunner.st loads a test-runer that is then used by the *-tests.st scripts to run the actual tests and produce a report.
  • Make sure that the last line of your script quits the image, e.g. by adding SmalltalkImage current snapshot: false andQuit: true.
  • For details see http://github.com/renggli/builder/blob/master/README.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜