How to test the Analyzer for an exercise concept? Java track

Hi,
I have implemented an analyzer for an exercise in the Java track.
I have seen that there are some unit test for the analyzers; from an old topic Implementing analyzer for gotta-snatch-em-all in the Java track - Exercism - Exercism, I have read this:

For the unit tests, its fine to just run the ones that are already there (assuming we add smoke tests for the analyzer). Once you’ve added them, run the docker script to run the tests.

I have ran both unit and smoke tests with docker, but I have noticed that the ones related to my analyzer are missing, such as “wizards-and-warriors-2”. Should I write them? If so, how to?

Yeah, we should tests to prove the changes work as intended. You’ll probably want to add a test for each comment that the analyzer can generate, plus one more for the exemplar solution. To the unit tests, you’ll need to:

  • Add tests for your Wizards and Warriors 2 to AnalzerIntegrationTest
  • For each comment that the analyzer looks for:
    • Add a sample to analyze in src/test/resources/scenarios. The sample should generate the intended comment.
    • Add the expected analyzer output to src/test/resources/analyzer.

If you need to see what the analyzer outputs (to figure out the expected analyzer output), you can run the test. The test would probably fail, but you’ll get a received.txt file.

There are also tests that run in Docker (in the tests folder). We should add them there too. Just adding to the tests folder (as per the other ones already there) should work.

1 Like

Okay, got it! thank you :slight_smile: