Acessing Junit Test results inside a test/Bestpractice?

I am currently writing a couple of tests for my system. Let's say i have function a and a function b that uses function a. I now want to implement it in a way, that if one of the tests for a fails the test b returns a message that it cannot work if a fails. My first question is, is this a good idea?

Secondly, so far i have been doing it like this:

Result result = JUnitCore.runClasses(TestA.class);
if (!result.wasSuccessful())
    fail("This test only works if a works")

But with this approach i can only check if a full class of tests works, not if a certain test works. How does one test check if another one failed? imagine they are both in the same class


This is generally not considered a best practice.

If your tests run quickly, then the simplest thing to do is just always run both tests. Doing what you have here just adds complexity.

In some cases, you can use Assume to cause a test to short circuit (without causing the test to fail) if a condition isn't true.

Need Your Help

Problem to put data in UITableView

iphone objective-c

- (void)requestFinished:(ASIHTTPRequest *)request

android accelerometer to measure speed

android accelerometer

im trying to make an speedometer using the accelerometer but for some reason the code is crashing can someone please tell me what is wrong and how to fix it

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.