📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
The assertNotSame() Method Example
import static org.junit.Assert.assertNotSame;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
public class JUnit5AssertNotSameExample {
private String processMap(final String key) {
final Map<String, String> map = new HashMap<>();
map.put("key1", "value1");
map.put("key2", "value2");
map.put("key3", "value3");
map.put("key4", "value4");
map.put("key5", "value5");
map.put("key6", "value6");
map.put("key7", "value7");
map.put("key8", "value8");
return map.get(key);
}
@Test
public void checkSameReferenceTest() {
final JUnit5AssertNotSameExample example = new JUnit5AssertNotSameExample();
assertNotSame(example.processMap("key1"), example.processMap("key2"));
}
}
Comments
Post a Comment
Leave Comment