eclipse like configuration in visual studio

  • Thread starter Thread starter alex
  • Start date Start date
A

alex

I am coming from eclipse world and java.
In java you have collection of classes and eclipse (IDE) allows you to
call
static main() methods of each class seperately (kind of quick test)

now i am working in c sharp and visual studio i figured out that it is
not really possible to do it -- each
project has one entry point so it is hard to have this flexibility

effectively is i have

class A { public static void Main() { a = new A(); a.runcode(); }}
class B { public static void Main() { b = new B(); b.runcode(); }}
.....
class Z { public static void Main() { z = new Z(); z.runcode(); }}


I would like to run either an instance of A or instance of B or
instance of
something else from IDE for quick testing


how can i retain the ability to run each class in the project
on its own -- it is great and convenient for quick test of whether
a class is working and to do bottom line design of the programs

many thanks

alex
 
alex said:
I am coming from eclipse world and java.
In java you have collection of classes and eclipse (IDE) allows you to
call
static main() methods of each class seperately (kind of quick test)

now i am working in c sharp and visual studio i figured out that it is
not really possible to do it -- each
project has one entry point so it is hard to have this flexibility

effectively is i have

class A { public static void Main() { a = new A(); a.runcode(); }}
class B { public static void Main() { b = new B(); b.runcode(); }}
....
class Z { public static void Main() { z = new Z(); z.runcode(); }}


I would like to run either an instance of A or instance of B or
instance of
something else from IDE for quick testing


how can i retain the ability to run each class in the project
on its own -- it is great and convenient for quick test of whether
a class is working and to do bottom line design of the programs

many thanks

alex

Depending on the version of VS you have, you may have a Test Project
template. We have it with Professional at work, but it is not in
Express. This template lets you set up tests sounding similar to what
you describe being available in Eclipse.
 
[...]
effectively is i have

class A { public static void Main() { a = new A(); a.runcode(); }}
class B { public static void Main() { b = new B(); b.runcode(); }}
....
class Z { public static void Main() { z = new Z(); z.runcode(); }}


I would like to run either an instance of A or instance of B or instance
of
something else from IDE for quick testing


how can i retain the ability to run each class in the project
on its own -- it is great and convenient for quick test of whether
a class is working and to do bottom line design of the programs

Depending on what version of Visual Studio you're using, it comes with a
complete unit-testing framework you can use.

If you're not using a version in which that's supported, seems to me the
next best thing is to simply have a single entry point, in which you have
calls to each class you think you want to execute code from (or a helper
method that does the appropriate thing). Just comment out everything but
the ones you want to use for a given execution.

Pete
 
I am coming from eclipse world and java.
In java you have collection of classes and eclipse (IDE) allows you to
call
static main() methods of each class seperately (kind of quick test)

now i am working in c sharp and visual studio i figured out that it is
not really possible to do it -- each
project has one entry point so it is hard to have this flexibility

effectively is i have

class A { public static void Main() { a = new A(); a.runcode(); }}
class B { public static void Main() { b = new B(); b.runcode(); }}
....
class Z { public static void Main() { z = new Z(); z.runcode(); }}

I would like to run either an instance of A or instance of B or
instance of
something else from IDE for quick testing

how can i retain the ability to run each class in the project
on its own -- it is great and convenient for quick test of whether
a class is working and to do bottom line design of the programs

many thanks

alex

Also, take a look at Nunit. This can be used if your Visual Studio
does not have support for Test Projects. I actually prefer using the
Nunit Test runner anyway (you can write test cases and run it either
with Microsoft's unit test project test runner or with Nunit).

As an eclipse user/Java programmer, I would probably never use the
approach you are saying. I always write Junit test cases and have a
suite to handle running all the code. Not sure what the value of
adding a main method to every class is, unless you actually intend to
use them as entry points to your application.

One other note about adjusting from Eclipse - the refactoring support
in Visual Studio is much weaker. (At least as of VS 2008). Hopefully
it will improve in future releases.
 
In the visual Studio project properties, you can specify which entry
point you want to use at a given time.
 
Back
Top