Console output not displayed for C# track exercises

At the bottom of the instructions for every C# exercise it says

When a test fails, a message is displayed describing what went wrong and for which input. You can also use the fact that any console output will be shown too. You can write to the console using:

Console.WriteLine("Debug message");

However, it doesn’t actually work. Regardless of whether the test succeeds or fails, any strings passed to Console.WriteLine() are not displayed in the results tab on the web editor. For example, in this solution for Task 1 of the Interest is Interesting exercise:

    public static float InterestRate(decimal balance)
    {
        Console.WriteLine("----------TEST----------");
        
        // return 100.0f;
        
        if (balance < 0) {return 3.213f;}
        else if (balance < 1000) {return 0.5f;}
        else if (balance < 5000) {return 1.621f;}
        else {return 2.475f;}
    }

The string "----------TEST----------" is not displayed anywhere in the test results. If you uncomment the early return statement so that the tests fail, the string still is not displayed in the results.

2 Likes

Hmmm, that’s odd. I’ll have a look.

I’ve been wondering if it’s something to do with XUnit update, as it’s been happening for a few weeks now.

It probably is. It should work out of the box.

Should be fixed by Allow capturing console and trace output by ErikSchierboom · Pull Request #299 · exercism/csharp-test-runner · GitHub

2 Likes