At times you may not want to run certain test cases in Junit, in such cases make use of the annotation @Ignore on such test methods.
Greeting.javapackage org.code2care;
public class Greeting {
public String wishMorning(String name) {
return "Hello " + name + ", Good Morning!";
}
public String wishAfternoon(String name) {
return "Hello " + name + ", Good Afternoon!";
}
public String wishEvening(String name) {
return "Hello " + name + ", Good Evening!";
}
}
GreetingTest.java
package myprog;
import static org.junit.Assert.assertEquals;
import org.code2care.Greeting;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
public class GreetingTest {
Greeting greeting;
@Before
public void init() {
greeting = new Greeting();
}
@Test
@Ignore
public void wishMorningTest() {
assertEquals("Hello Neo, Good Morning!", greeting.wishMorning("Neo"));
}
@Test
public void wishAfternoonTest() {
assertEquals("Hello Neo, Good Afternoon!", greeting.wishAfternoon("Neo"));
}
@Test
public void wishEveningTest() {
assertEquals("Hello Neo, Good Evening!", greeting.wishEvening("Neo"));
}
}
Test Run Results:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running myprog.GreetingTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.012 sec
Results :
Tests run: 3, Failures: 0, Errors: 0, Skipped: 1

-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Java,
- Java equals method - Tutorial
- Unbound classpath container: JRE System Library [JavaSE-1.7]
- Spring Boot: @RequestBody not applicable to method
- Java 8: Steam map with Code Examples
- Java Program: Random Number Generator
- Java java.time.Clock class code examples [Java Date Time API]
- Fix: type argument is not within bounds of type-variable T
- [Fix] java.net.MalformedURLException: unknown protocol
- Java 7 addSuppression() and getSuppression() Exception Handling
- Convert Java Array to ArrayList Code Example
- How to Word-Warp Console logs in IntelliJ
- Ways Compare Dates in Java Programming with Examples
- Remove Trailing zeros BigDecimal Java
- CRUD operations in Spring Boot + JDBC
- [Java Threads] Should we extend Thread Class or implement Runnable interface
- Json Serialization and Deserialization using Java Jackson
- Create simple struts2 project using maven commands
- How to install Java OpenJDK 11 on Alpine Linux
- Unsupported major.minor version 52.0 in java
- Error: Can not find the tag library descriptor for
- Java: Convert String to Binary
- How to run Java Unit Test cases with Apache Maven?
- Java: Testing Private Methods in JUnit using reflection API Example
- Java JDBC Connection with MySQL Driver in VS Code + Troubleshooting
- Java Join Strings with Comma Separator
More Posts:
- How to Rename a Git Local Branch Using the --move Option - Git
- java.lang.ClassNotFoundException android.support.v7.widget.Toolbar [Fix] - Android
- How to open CMD for current file/folder location in Notepad++ - NotepadPlusPlus
- How to install iTerm2 Mac Terminal Alternative - MacOS
- 10 Must Know CSS Border Styles with Examples - CSS
- The Zsh Shell - Mac Tutorial - MacOS
- Android : Remove ListView Separator/divider programmatically or using xml property - Android
- 10 Beginners Commands for macOS Terminal Usage - MacOS