Menu

Testing student submissions

2002-08-27
2012-09-04
  • Christopher P. Jobling

    How does one set up a programming exercise for a student? The documentation describes how the database is informed of a test but details are scant as to how the actual Java code is tested.

    Presumably a teacher would need to devise some Java test class that exercises the student's code but what form does this take. Where is it located? How is BOSS/Cobalt made aware of it. Where is the link established between the test code and the assignment?

    Let's say that my first exercise is "hello world" and I want to have my students write a class

    class Hello
    {   String sayHello()
        {   return "Hello, World!";
        }
    }

    A suitable test would be:

    class HelloTest
    {   public static void main(String[] args)
        {   Hello h = new Hello();
            String test = n.sayHello();
            if ("Hello, World!".equals(test))
               System.out.println("Test passes");
            else
               System.out.println("Test fails");
         }
    }

    Taking this example, could you possibly tell us how BOSS actually would be set up to mark a solution to the Hello class. I'm sure it would help everyone who is evaluating BOSS.

    Chris

     
    • David Buckley

      David Buckley - 2004-08-02

      Hi! Apologies for the extremely late reply; there's two ways to do this as it stands.

      First, you can ask your students to provide the main method and ask them to call their class "Hello", then create a BOSS test with standard output set to "Hello, World!", input and error blank and a command line of "java Hello."

      The second, and probably neater way is to instead use a JUnit test. BOSS will give you a skeleton one initially; all you need to do is fill in the setUp and tearDown entries if you like, and add methods starting with the word "test" (there should be a testSomething there initially for you). In this case, you'd want something like:

      public void testHello() {
         Hello h = new Hello();
         assertTrue(h.sayHello().equals("Hello, World!"));
      }

      Both tests can now be set up using either the web or GUI clients.

       

Log in to post a comment.