Reputation: 29816
I am writing a web application and there I have created a class with Main method. I am in VS2010.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Dao {
/// <summary>
/// Summary description for User
/// </summary>
public class User {
public User() {
//
// TODO: Add constructor logic here
//
}
public static void Main(String[] args) {
Console.WriteLine("JYM");
}
}
}
Is there any way to run that particular class's Main() without running the complete application?
The purpose is for testing.
Upvotes: 2
Views: 3099
Reputation: 3780
I assume you are trying to write unit test for your applications.
In case if you are using the inbuilt MS-Test for this, you can debug your tests from the Test menu.
Test -> Run -> ....options for running tests...
In the Test results window you can see all the tests and debug using the debug option.
In case if you are using NUnit for this, you need to create a new C# console applicaition and add a reference to the test project and then call the class and methods of your test project in this console applicaiton and debug them.
Upvotes: 3
Reputation: 2907
Visual Studio 2010 a 'Test' menu in the menu bar. Pick 'New Test', and use the wizard. It will make a secondary project that is dependent on your main project, and you are supposed to run the secondary project to run your tests.
At least, it let's me do that for a normal DLL or EXE. I'm not sure about a web application; but you should try it out.
Upvotes: 2