Friday, 26 February 2021

DisallowWriteToSystemErr: Disable System error messages

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

 

DisallowWriteToSystemErrTest.java

package com.sample.app.tests;

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

public class DisallowWriteToSystemErrTest {
	@Rule
	public final DisallowWriteToSystemErr disallowWriteToSystemErr = new DisallowWriteToSystemErr();

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

 

You can download complete working application from this link.

https://github.com/harikrishna553/system-rules

 

 

 

  

Previous                                                    Next                                                    Home

No comments:

Post a Comment