Compsci 6, Fall 2011, Snarfable APTs

Background

The APTs we do in class are available via 'snarfing' so that you can test and run in Eclipse.

Use the Ambient Snarfer Site window and choose one of the APTs you want to snarf as shown in the screen capture below. There I chose apt_acronym.

snarfable apt

After snarfing the APT, you can see it and the source files that come with it.

snarfable apt

Every APT you snarf will have several files in the src folder including python modules ETester.py, Parse.py, and StoppableThread.py. These are part of the APT testing framework and you can ignore them (except for ETester.py which you'll run as shown below). DO NOT MODIFY any of these files.

You'll need to create a Python module that's specific to the APT you're doing. Click on the src folder and select "new", "Python Module". It is important that the file name is exactly as it appears on the APT page. In this case the the specs on the APT page for this problem state that the APT module should be called CreateAcronym. Note you can leave the Package blank and type the name of the module where it says "Name". Note you do not need to add the .py extension as it is added automatically.

snarfable apt

In the screen capture below you can see that I've started code for CreateAcronym.py in the snarfed project and I'm ready to test a simple (and wrong) implementation.

snarfable apt

Running the APT to test

Instead of running CreateAcronym.py you need to run the module ETester.py which will all the code you wrote in CreateAcronym.py. For every APT you implement in Eclipse, you'll run ETester.py to test the module and function you wrote for the APT. The ETester.py module you snarf is specific to the APT you're doing. To run, click and highlight Etester.py and select "Run as", "Python Run".

Seeing Results

Running ETester.py will generate two new files in the src folder. One called results.html and one called perc. To see these in the folder you may need to select src and right-click and select Refresh. I did this and notice these new files now in the src folder.

snarfable apt

Then you can simply click on the results.html file to see your results. In the screen shot below I can see some I got correct (green) and some I got wrong (red).

snarfable apt

If you scroll further down you will see more information as shown below. Here for test case 4, the input was the string "A B C", the expected answer was "ABC" and my program got the incorrect answer "A". Test case 5 shows that I got the correct answer.

snarfable apt

After fixing your code, save the file, run ETester.py and then you may have to refresh the results in src again to see the new results. The goal is to get all green!