JAVA EXAMPLE PROGRAMS

JAVA EXAMPLE PROGRAMS

Publish Your Article Here

Program: Assertion method Assert.assertFalse() example.


Java Class: org.junit.Assert

Assert class provides a set of assertion methods useful for writing tests.

Assert.assertFalse() methods checks whether the expected value is false or not.


package com.java2novice.junit.tests;

import org.junit.Test;
import static org.junit.Assert.*;

public class MyAssertFalseTest {

	public boolean isEvenNumber(int number){
		
		boolean result = false;
		if(number%2 == 0){
			result = true;
		}
		return result;
	}
	
	@Test
	public void evenNumberTest(){
		MyAssertFalseTest asft = new MyAssertFalseTest();
		assertFalse(asft.isEvenNumber(3));
	}
}

<< Previous Program | Next Program >>

Java JUnit Examples

  1. Simple JUnit test using @Test annotation.
  2. List of JUnit annotations.
  3. Assertion method Assert.assertArrayEquals() example.
  4. How to do JUnit test for comapring two list of user defined objects?
  5. Assertion method Assert.assertEquals() example.
  6. Assertion method Assert.assertFalse() example.
  7. Assertion method Assert.assertTrue() example.
  8. Assertion method Assert.assertNotNull() example.
  9. Assertion method Assert.assertNull() example.
  10. Assertion method Assert.assertNotSame() example.
  11. Assertion method Assert.assertSame() example.
Knowledge Centre
Domain Naming Service(DNS)
It is very difficult to remember a set of numbers (IP address) to connect to the Internet. The Domain Naming Service(DNS) is used to overcome this problem. It maps one particular IP address to a string of characters. For example, www.java2novice.com implies com is the domain name reserved for US commercial sites, java2novice is the name of the company and www is the name of the specific computer, which is java2novice's server.
Famous Quotations
Education is what remains after one has forgotten what one has learned in school.
-- Albert Einstein

About Author

I'm Nataraja Gootooru, programmer by profession and passionate about technologies. All examples given here are as simple as possible to help beginners. The source code is compiled and tested in my dev environment.

If you come across any mistakes or bugs, please email me to [email protected].

Most Visited Pages

Other Interesting Sites

Reference: Java™ Platform Standard Ed. 7 - API Specification | Java™ Platform Standard Ed. 8 - API Specification | Java is registered trademark of Oracle.
Privacy Policy | Copyright © 2022 by Nataraja Gootooru. All Rights Reserved.