Search code examples
c#.netwindowswindows-services

Testing Windows Service in .Net


I'm developing a windows service in C# .Net and i'm having some dificulty to execute and test my service. I'm using a timer component to run it from time to time and execute my methods. I have to intialize the service all the time to run it. Anyone know a more practical way to test a service?


Solution

  • You probably want to add unit tests to your service.

    It sounds like you could benefit more from adding your application to the Task Scheduler instead of running it as a service.

    Other than that if you really need it as a service you need to design it so it can be tested. I usually write my services in a separate class and add a .EXE project to it so I can run it from the command line too.