print the content of Vector in assertEquals()

  • Thread starter Petterson Mikael
  • Start date
P

Petterson Mikael

Hi,

I have the following in my test:
public void assertSubscToNot(Vector zeroTimesSignal,
Vector moreThanOneTimesSignal,
Vector nullRequestSignal) {
assertEquals("Subscription occurred >1 time. ", 0,
moreThanOneTimesSignal.size());
assertEquals("Subscription occurred 0 times. ", 0,
zeroTimesSignal.size());
assertEquals("Null request signal ", 0, nullRequestSignal.size());
}


The problem i have is that I need to print the content of the Vector
when it is unequal. Any hints on how I can do this?

cheers,

//miakel
 
B

Bart Cremers

You can wrap the assertEquals statements in a try/catch statement:

try {
assertEquals(...);
} catch (AssertionFailedError e) {
// Print contents here
throw e; // Rethrow to make the test fail.
}

Regards,

Bart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,871
Messages
2,569,919
Members
46,172
Latest member
JamisonPat

Latest Threads

Top