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

-
Have Questions? Post them here!
More Posts related to Java,
- How to Get List of All Country Codes in Java Using Locale Class
- Unsupported major.minor version 52.0 in java
- Java - How to set custom thread name?
- Get the current timestamp in Java
- Java Spring Boot 3 Web Hello World with Gradle in IntelliJ
- [fix] NullPointerException Cannot Invoke findById because Repository is null - Java Spring
- java: unclosed string literal [Error]
- Convert Java Byte Array to String with code examples
- Error: Can not find the tag library descriptor for
- Java 8 - Convert List to Map Examples
- Java - Calculate time taken for the code to execute in milliseconds or nanoseconds
- Fix java.net.ProtocolException: Invalid HTTP method
- Java: Convert Stream to List
- Java equals method - Tutorial
- List of Java JDBC Database Driver Jars, Classes and URLs Details
- Read YAML file Java Jackson Library
- How to display Java Date Time timezone GMT/UTC offset using SimpleDateFormat
- List of Java Keywords
- Enable JSON Pretty Print in Java Jackson
- How to Word-Warp Console logs in IntelliJ
- Convert Map to List in Java 8 using Stream API
- Create a Directory using Java Code
- Ways to Convert Integer or int to Long in Java
- [Program] How to read three different values using Scanner in Java
- Java JDBC Example with Oracle Database Driver Connection
More Posts:
- Android M cannot run app using play button : Android Studio - Android
- Android : Execute some code after back button is pressed - Android
- Convert String Date to Date Object in Java - Java
- Open VS Code Command Palette using Keyboard Shortcut - Shortcuts
- Fix Microsoft Teams error We're sorry—we have run into an issue Try again - Teams
- Java - Calculate time taken for the code to execute in milliseconds or nanoseconds - Java
- Install Microsoft OneDrive on Mac - MacOS
- How to Adjust macOS System Font Size - MacOS