In JUnit, you can skip a method by either commenting it out or by renaming the method so that its signature does not represent a test method signature. An easy way to skip a test method is to precede its name with an X. For example, you could rename testCreate to XtestCreate. JUnit looks for methods whose names start with the word test, so it will not find XtestCreate. You do not want to make a habit of commenting out tests. It is poor practice to leave methods commented out for any duration longer than your current programming session. You should avoid checking in code with commented-out tests. Other developers won't understand your intent. My first inclination when I see commented-out code, particularly test code, is to delete it. Commenting out test methods is risky. It is easy to forget that you have commented out tests. It can also be difficult to find the tests that are commented out. It would be nice if JUnit could warn you that you've left tests commented out. A similar problem exists for your new TestRunner class. The simplest way of bypassing a test would be to remove its @TestMethod annotation. The problem with doing that is the same as the problem with commenting out a test. It's easy to "lose" a test in a system with any significant number of tests. For this exercise, you will make the necessary modifications to TestRunner to ignore designated methods. You will create a new annotation type, @Ignore, and change code in TestRunner to recognize this annotation. The @Ignore annotation will allow developers to supply a parameter with a text description of why the test is being skipped. You will modify TestRunner to print these descriptions. |