Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Why isn't @Ignore working in this code?

 
Author
Posts: 133
10
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class NumberHolder {
public int i;

public NumberHolder(int i) {
this.i = i;
}

public int increment() {
// return i++;
return i + 1;
}

public int decrement() {
// return i--;
return i - 1;
}

}

import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class NumberHolder_TEST extends TestCase {
NumberHolder holder;

@Before
public void setUp() {
System.out.println("Setting up...");
holder = new NumberHolder(42);
}

@Test
public void testIncrement() {
System.out.println("Testing increment...");
assertEquals("Increment not working!", 43, holder.increment());
}

@Test
public void testDecrement() {
System.out.println("Testing decrement...");
assertEquals("Decrement not working!", 41, holder.decrement());
}


@After
public void down() {
System.out.println("Done");
}

@Ignore("A test is NOT being performed.")
@Test
public void testDecrement2() {
System.out.println("Testing decrement again...");
assertEquals("Decrement not working!", 40, holder.decrement());

}

}
 
Barry Burd
Author
Posts: 133
10
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind! I figured it out. I used "extends TestCase" instead of import static org.junit.Assert.*;
 
    Bookmark Topic Watch Topic
  • New Topic