Thanks for your reply. I have not created an object of the class which I am testing. Where should i create its object? The name of the class which I am testing is PrintGrades. I dont have any'main' method in this class. Should I provide a main method and then create its object in the main and then call the method print(...), using the following code
Is the main method necessary in the class which I have to test?
Please guide me.
First off, use the recommended naming conventions and use strong types over string. You will also want to declare your methods as static if they don't need a reference to instance fields. Don't declare variables if you're not going to use them. You're not dong anything useful with strGrade.
The final result would become something like this:
Your test method becomes something like this:
You don't need to create an object, because the method is static. Your current test fails because you explicitly let it fail by calling fail().