Questions tagged [system-rules]

System Rules is an Open Source Java library which makes it possible to test code which uses java.lang.System.

System Rules is an Open Source Java library which makes it possible to test code with which uses java.lang.System.

12 questions
3
votes
2 answers

Identical Content But JUnit Test Fails(IntelliJ)

I have a JUnit Test that compares two strings: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = CDPlayerConfig.class) public class CDPlayerTest { @Rule public final SystemOutRule log = new…
Rajkishan Swami
  • 3,569
  • 10
  • 48
  • 68
2
votes
1 answer

could not find org.junit.contrib package

I use maven to build my project and JUnit to test. When I tried to do test using SystemOutRule, I could not find this class and could not find org.junit.contrib package. p.s. My JUnit is the latest version, 4.12. my Maven pom.xml
Quentin Liu
  • 141
  • 1
  • 10
2
votes
2 answers

System rules returns different line separator

I have a spring test class from Spring in Action 4th which tests simple class that prints something to standard output. It uses System-Rules library incorporated into junit. When I run the test it throwed ComparisionException - the only difference…
ashur
  • 4,177
  • 14
  • 53
  • 85
2
votes
2 answers

ExpectedSystemExit is causing the error

I'm using the library System Rules to testing method that calls System.exit(): @Rule public final ExpectedSystemExit exit = ExpectedSystemExit.none(); Unfortunately, this piece of code is causing the error ... initializationError caused an ERROR:…
1
vote
1 answer

Simulation of JUnit output for the given input

public void MyTest { @Rule public final TextFromStandardInputStream systemInMock = emptyStandardInputStream(); @Test public void shouldTakeUserInput() { systemInMock.provideLines("add 5", "another line"); InputOutput inputOutput =…
1
vote
1 answer

Using JUnit temporary folders and checking file existence on system exit

I have a unit test like this, using org.junit.contrib.java.lang.system.ExpectedSystemExit org.junit.rules.TemporaryFolder @Rule public TemporaryFolder folder = new TemporaryFolder(); @Rule public final ExpectedSystemExit exit =…
dwjohnston
  • 11,163
  • 32
  • 99
  • 194
1
vote
1 answer

Using Junit to mock user input to Scanner object

I'm very new to JUnit and Unit Testing and have a question regarding mocking user input to the Scanner object. I have the following code that I would like to test. Very Basic. Run Code import java.util.Scanner; public class MyGame{ public…
salce
  • 409
  • 1
  • 12
  • 28
1
vote
2 answers

What is causing to JUnit and System Rules to fail on this Student's Submission?

I've been working off an automatic grader for the past month and one of my students that understands the material seems to continually fail my JUnit test cases due to returning 'null'. Since it is a Java I course, they are still using…
tsumnia
  • 454
  • 4
  • 18
0
votes
1 answer

Received a failure event for test with unknown id, Gradle, Junit4, SystemRules

When running gradle test I receive an error Caused by: java.lang.IllegalArgumentException: Received a failure event for test with unknown id '16.3'. Registered test ids: '[16.1, 16.2, :app:test] This error only occurs when tests include…
0
votes
1 answer

Junit and jenkins org.junit.contrib.java.lang.system.internal.CheckExitCalled: Tried to exit with status 0

I try to run junit tests in parallel. But while my test has to finish they dont't. My jenkins running and seems like not gonna end. The error is: org.junit.contrib.java.lang.system.internal.CheckExitCalled: Tried to exit with status 0. at…
java_user
  • 929
  • 4
  • 16
  • 39
0
votes
1 answer

Using System Rules to intercept System.exit() fails with Swing windows

I'm tasked with setting up some JUnit tests for a utility app that is required to System.exit(1) under various circumstances, and System Rules is great for testing that. The app can also run in GUI mode and it pops a small JFrame. When it's…
dave thompson
  • 133
  • 3
  • 9
0
votes
1 answer

System Rules not finding emptyStandardInputStream(); method

The std coding example shows the emptyStandardInputStream() method. But the compiler can't resolve it. @Rule public final TextFromStandardInputStream systemInMock = emptyStandardInputStream(); Rule - yep, got that. TextFromStandardInputStream -…
Simon
  • 39
  • 3