Unit testing, teaching, and sketching

Ahoy p5.js forums!

I'm teaching coding to humanities students next semester, and this is my first time using p5.js and JavaScript to do it. I'm contemplating using something like a TDD workflow for students (to be sure, a pedagogical approximation), using Jasmine or Mocha to build a test.html file for each project according to spec. Get all the tests to turn green, the project is done! (Or, rather, it's time to start refactoring your code.)

I have a few questions for teachers and students:

  1. TDD seems a bit anathema to the "sketching with code" metaphor that organizes Processing and p5.js; is this actually a good idea? (I just know I would have been so much happier had the TDD testing model been around when I was learning to code.)

  2. Has anybody done/used something like this? How did it go? What worked/didn't?

  3. Has anybody built something like this? Before I set to building the thing myself without a plan, I thought I'd see if folks in the p5.js community had done some of the foundation work. (Also, if there are obvious places to start with the p5.js testing suite itself, I'd love a pointer to where I might look. I haven't started digging around there yet, and a local guide would be most welcome.)






  • edited November 2015

    I'm afraid unit testing is too "advanced" for a topic around here. X_X
    And actually it's not p5.js specific. Which is meant for beginners after all.
    I suggest you present the issue at some Reddit JS sub like these 2:

    1. https://www.Reddit.com/r/javascript/new/
    2. https://www.Reddit.com/r/LearnJavascript/new/

    Or even here: https://www.Reddit.com/r/processing/new/

    P.S.: GitHub's repo for p5.js relies on unit testing a lot. Check it out: O:-)

  • This is interesting, but I'll agree that introducing unit testing does seem a bit counter-productive to Processing's goal of being light, quick, fun, and easy to "sketch" little projects.

    You might want to check out Daniel Shiffman's stuff, particularly his Nature of Code book and class. He's another teacher that uses Processing, and he publishes his lesson plans and curriculums, plus teaches Processing through his youtube channel. If I was a Processing teacher, this would be the first thing I look at.

  • edited November 2015

    For p5.js, I'd jump directly into Shiffman's Vimeo lesson videos: *-:)

  • +1 for not taking this approach

    • You: "great - it passed the test!"
    • Student: "yeah, but what does it actually do..."

    If you had said you were teaching Computer Science students who would be building large scale applications I would have understood; but unit tests are overkill for the sort of small scale code-base your humanities students are likely to be working with (early on at least!). And how will you explain to them how the unit test can pass, but the script still breaks because of some unsupported feature in their browser of choice?

    I'd instead recommend teaching them good coding practice (particularly relevant with JS. e.g. "use strict" catches lots of beginner bugs like globally declared vars) and how to debug in the browser; and make sure they see interesting results... fast.

Sign In or Register to comment.