Showing posts with label junit. Show all posts
Showing posts with label junit. Show all posts

Friday, May 25, 2012

What"s the proper way to test a class with private methods using JUnit?


How do I use JUnit to test a class that has internal private methods? It seems bad to change the access modifier for a method just to be able to run a test.

Wednesday, April 25, 2012

How to run all tests belonging to a certain Category in JUnit 4


JUnit 4.8 contains a nice new feature called "Categories" that allows you to group certain kinds of tests together. This is very useful, e.g. to have separate test runs for slow and fast tests. I know the stuff mentioned in JUnit 4.8 release notes , but would like to know how I can actually run all the tests annotated with certain category.

Tuesday, April 17, 2012

Can I test status bar notifications using Android"s testing framework?


I have a class that sends a status bar notification in Android. I can't find a way to test whether the notification was sent or not, which makes it very hard to write any kind of useful unit test.

Wednesday, March 7, 2012

differences between 2 JUnit Assert classes


I've noticed that the JUnit framework contains 2 Assert classes (in different packages, obviously) and the methods on each appear to be very similar. Can anybody explain why this is?

Wednesday, February 29, 2012

Monday, February 20, 2012

How should I be creating classes when doing TDD


I have started doing TDD and I am unsure if I am doing it correctly. I have made a Question class and a QuestionTest. The Question class has an addAnswer method that takes an instance of the Answer class. Now, should I be creating only the class Answer and use the default constructor. Or should I be making the Answer class and also provide the constructor with parameters?