Picking the right test project [closed] - c#

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I have been learning C# for one and a half year and I also learn Java from time to time. I don't have much experience yet and especially when it comes to testing my code and until now I have always tested manually by interacting with the GUI or writing small test programs. Recently while learning Java I came across JUnit testing and I wondererd if the same exists for Visual C#. In Visual Studio 2017 I have the option of creating a MSTest Test Project, NUnit Test Project, xUnit Test Project or Unit Test Project.
I have found examples of people using these different projects but I couldn't figure out what's the big difference or which one should be used when.

Microsoft has it's own test framework, aptly named 'MSTest', which is a simple and easy way to get started. OFten, you'll see complaints from people who find it slow, however, a few tweaks to the settings here & there, and you'll find it performs briliantly.
However, there are more popular test frameworks such as nUnit, xUnit. All have good documentation on how to get started, and these days, there aren't too many differences between them. xUnit has some neat features that you may find interesting, however, it's first in advanced scenarios that these frameworks differ, and you'll have to have pretty specific needs before you find a limitation.
I would suggest you to start on MSTest, nUnit or xUnit, try them out, make one DLL for each of them in your project and see which one you like more.

The different frameworks are not that very different. I would recomend xUnit or NUnit, I prefer xUnit, but it is more of an syntax issue. I think most of them support parameterized input now. The most important is that you create unit tests!

Related

Testing framework for C# WPF application [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have already created C# WPF application and I would like to create test application for same.
I have searched for that on Internet, I have found below test framework :
Nunit
Robot framework
Unit testing
I am confused to select the best test framework for C# WPF application.
Can you please suggest me
Use an accepted pattern such as MVVM to ensure that there’s no business logic in the UI.
Use NUnit or similar to test the business logic.
Don’t bother with automatically testing the view. It should be simple enough so if it looks right, it is right.
I assume your question is about unit test frameworks.
NUnit is well tested and proven to work. I don't know about the other two but there's also Microsoft's one and xUnit. You really should check xUnit out: https://xunit.github.io/docs/why-did-we-build-xunit-1.0.html
It's actually just a matter of preference. Go after the one you feel comfortable with. Test the others and decide. I can recommend you xUnit as I work with it myself. There's no the best.
You don't really need a third-party framework for writing unit test if you don't want to. You could just create a Unit Test Project (Templates->Visual C#->Test->Unit Test Project) using the built-in Visual Studio template.
You would then add a reference to the project where your view model classes are implemented and write unit tests against these:
[TestMethod]
public void SomeTest()
{
var vm = new YourViewModel();
vm.PropertyA = "a";
Assert.IsNotNull(vm.PropertyA);
}
Of course this assumes that you have implemented your application with testability in mind. MVVM is the recommended pattern to use when developing XAML based UI applications. If you haven't learned it yet, you should. MSDN provides a good starting point: https://msdn.microsoft.com/en-us/library/hh848246.aspx.

C# test application [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I a have a solution containing 25 projects comprised of both C# and managed C++.
I need to test one of the C# project calls but this project is of type "Window application" (Not DLL).
Even though it is a windows application, my requirement is to call only few internal functional calls (Not related to windows form).
I need to create a separate C# test project to call this functionality. Is it possible to do it like this?
Can anyone suggest a way or examples? And one more thing, I cannot modify the existing code.
Is it possible to do it like this?
Yes. Referencing the project you wish to test in a test project is typically how you unit test your code.
Can any one suggest a way or examples?
Create a unit test project, reference the project that contains the code you wish to test, write tests to test the code you wish to test. If you need to refactor the code to make it testable, do so, or see point below.
And one more thing, i don't have any freedom to modify the existing
source code.
In this case, you are going to have to wrap the code in some cleaner interfaces to allow you to test the code.
The book, Working Effectively with Legacy Code by Michael Feathers has some excellent advice on how to get legacy code under test.

Moving to next project version [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm starting on the second version of a large Solution/Project that I created and was wondering about the best way to go about it. I'll be changing allot of the core code, classes and projects of the solution and that makes want to make this into a separate solution and separate repository.
I've never really started on a version 2 before, so if anybody could give me advice on the best way to go about it I would truly appreciate it.
For the record I am coding in C# and using VS2012.
Thank You
Create a Branch in the repository called Version2 or something (maybe a better code name) and do all the new dev work in that. That way you still have the original Trunk if you need to go back to it. Maybe also create a Tag with the current project that will never change so you basically take a snapshot of it before making any substantial changes.
I usually keep everything in one solution and just evolve the solution. There are several benefits to this:
You refactor your tests along with the project (hope you do have some!)
Keep a tracked version of all the changes in your source control
It's easier to make sure your project is still stable after the refactoring by running test suits or running the executables in debug mode
It is safer to refactor little bits and peaces, than a global re-write, there is a risk you will go a little bit to far with refactoring

breaking up a monolithic project [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am about to break a monolithic WPF/C# application into manageable modules. Please let me know what are the points i need to remember before breaking the software. Any tools that would be handy,etc.
Thanks in advance.
Regards,
JOhn.
Depending on your tool set there are a couple of things which generally help when analyzing a code base from an architectural or structural viewpoint.
In VS 2010 Ultimate or with a tool like nDepend you can generate dependency graphs which help you see you application's dependencies and code usage can be useful when trying to break large code into smaller api's or services.
Also unit tests and integration tests can help ensure that functionality is maintained without introducing bugs and using refactoring tools like resharper, justCode or coderush can really help to adjust your namespaces, code file physical locations and class/method signatures when dealing with a large codebases into smaller more manageable libraries and projects.
On the planning side you really need to establish the key elements of the application from a separation of concerns point of view to define the boundaries of each module.
Probably the worst thing you can do though is just launch in and start hacking the code into chunks. Mapping out a phased migration for one module at a time would be my strategy of choice.
Agree with the above comment though that the question is too broad to get any meaningful answers.
Your question is very broad as there are many techniques (e.g. heavily unit testing your code) that are of help. It is probably best to read a book on that topic. I can highly recommend you Michael C. Feathers
Working Effectively with Legacy Code
Although this book is mostly Java-centric the described techniques are generally applicable. It will definitely change the way you write and think about code and will be of help when working with existing applications.
Feathers' book is also one of the books that are most recommended in this SO post.
To complete Mac answer on tooling such as NDepend (Disclaimer: I am a developer of the tool NDepend) I'd advise to read these 2 white books on how to partition your code in assemblies, layers and components. This is certainly the key to break your monolithic code base.
Partitioning code base through .NET assemblies and Visual Studio projects (8 pages)
Defining .NET Components with Namespaces (7 pages)

Visual Studio 2008 Training [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I've been put in charge of coming up with a training itinerary for my team at work for a migration from c++ to Visual Studio 2008 with C#.
The actual language switch I'm not too worried about, its the learning curve to Visual Studio. What does everything think would be the best way to set up a training course?
I was thinking of having a list of different features of the IDE and having the team members create pages on our internal wiki on them, but I'm not sure if that would be hands on enough to be useful.
We are a C++ shop, that is moving to C# for UI work (our image processing and 3D graphics code will stay in native C++). I found C# for C++ Developers a very quick and handy introduction to the language. Our team has been using Visual Studio for while, whereas I came from an SVN/Slickedit/CMake/Ant kind of environment in my last job. I found it very helpful to just dive in and start working, but as I figured things out, I documented them on our internal wiki. It's been about 6 months, but not only am I very comfortable with Visual Studio, but the rest of the team has had me streamlining our build process, and converting our build system to do out-of-place builds from Visual Studio (which I document on the wiki, of course). So I'd say do both - dive in and do real work, but document what you learn - which not only helps others, but it reinforces it in your mind.
I think you're right to worry that the wiki thing wouldn't be hands-on enough.
How about using it as an opportunity to refresh your process too, and do a mini project "Bootcamp" where you test drive the new language and IDE features along with some new development practices. Actually create a piece of software over the course of a week or so.
MS has Visual Studio training kit. I think the best way is to teach the basics and then start using it in projects. Let them learn the features they need as they are using it on a project.
I found Pluralsight a really good way to start training up a team. Learnvisualstudio.net is pretty good too.
I purchased the on-demand training from pluralsight about 4 months ago and IMHO is the best training out there.
link text

Categories

Resources