Friday 26 February 2021

DisallowWriteToSystemOut: Disable System output messages

‘DisallowWriteToSystemOut’ class make the test fail, if the test tries to write some data to System.out.

 

DisallowWriteToSystemOutTest.java

package com.sample.app.tests;

import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.DisallowWriteToSystemOut;

public class DisallowWriteToSystemOutTest {
	@Rule
	public final DisallowWriteToSystemOut disallowWriteToSystemOut = new DisallowWriteToSystemOut();

	@Test
	public void thisTestFail() {
		System.out.println("Hello World");
	}
}

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment