erikbstack
erikbstack

Reputation: 13254

Eclipse Java Console: Why sometimes no output?

I often make the experience, that the Console view in Eclipse gives confusing results. With most confusions (like error outputs written between some standard outputs), but with one type I can't live at all. Sometimes you have a System.out.println(); somewhere in your code and you can validate that the code before the sysout and the code after it will be executed, but still you will not see any result printed to the console. Why is that?

At the moment I saw this in a JUnit4 test (but it's not the first time). My test looks something like this:

@Test
public void testSomething(){
  //prep
  ...
  String expected = ...
  //exec
  String actual = executeTestcase();
  //assert
  System.out.println(Formatter.doSomeformatting(actual));
  Assert.assertEquals(expected, actual);
}

Upvotes: 0

Views: 6286

Answers (3)

johngreen
johngreen

Reputation: 2744

In my case, a previous program had not terminated and it's console was still running. I had to terminate that console manually and viola, I started getting outputs on the console again.

Upvotes: 0

Logan
Logan

Reputation: 2505

In my case too I am able to use assertEquals and all similar stuff in TestCase and TestSuite,but when you want to use assert in normal program, you need to enable assertion (which is disabled by default).

To enable assertion, Select your file->Run As->Run Configurations->There select Arguments tab and in that there is text box labeled as VM Arguments. In this text box write this command: -ea.

Source: Solved same problem today on my colleagues Computer.

Upvotes: 0

user591593
user591593

Reputation:

enter image description here

Perhaps you were not selecting the correct console?

Upvotes: 5

Related Questions