I'm really banging my head against the wall here. Is it so hard to get program output in Visual Studio (Express 2013)? When writing code, I find it absolutely essential to be able to print out the values of variables, operations etc. while working and troubleshooting.
In Java and Eclipse, the System.out.println() allways works, printing to the IDE console. When writing C programs I allways use the console, so echoing anything is no problem. However, in VS Express 2013 I can't seem to get any output.
Can the problem be related to the fact that I'm writing unit tests, and not "normal" executable programs? If so, is there some way to get VS to show program output in unit test classes? I've tried using debug, but that doesn't show anything either. Thinking that there's a config problem, I've looked for solutions to debug messages not showing, but none of the options I've found (in here or other places) seem to help.
Or, of course - if there's another commonly used method for checking program values, output etc. while writing code in VS/C#, I'd like to hear about it :-)
Anyone got any ideas? And please, if the question is too unclear or something, tell me and I'll fix it.
NB: I'm using unit test classes for functional testing, in case someone wants to point out what I should and and shouldn't do with unit tests.
EDIT 1: I forgot to mention that I'm not able to run the code with "Start: Debug". If I try, I get this error: "A project with an Output Type of Class Library cannot be started directly." (The unit test project uses classes in another project, which i a class library project.) This is, of course, because I have no executable project in the solution. The way I run it is to run the selected test, from the Test Explorer.
EDIT 2: Code:
using System;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WordpressAutomation;
namespace WordpressTests
{
[TestClass]
public class LoginTests : WordpressTest {
[TestMethod]
public void AdminUserCanLogIn() {
System.Diagnostics.Debug.WriteLine("Something...");
System.Diagnostics.Trace.WriteLine("Something...");
}
}
}
To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug. In Test Explorer, select the test method(s) and then choose Debug on the right-click menu.
In the main menu of VS, choose View > Output, then within the Output pane, pick "Tests".
To generate unit tests, your types must be public. Open your solution in Visual Studio and then open the class file that has methods you want to test. Right-click on a method and choose Run IntelliTest to generate unit tests for the code in your method. IntelliTest runs your code many times with different inputs.
The TestExplorer of Visual Studio has a separate output window. It does not write to the default Output of Visual Studio (I do not know if it is configurable)
You have to select the Test you want to see the output in the TestExplorer. If Test has some Output you should see a Hyperlink "Output". Clicking that will open a new tab displaying the output of the Test.
The displayed messages are all written by Console.WriteLine
.
I´m using Visual Studio 2013 Professional. I´m not sure if the Express version works diffrent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With