How to run JUnit test cases from the command line

For JUnit 5.x it’s: java -jar junit-platform-console-standalone-<version>.jar <Options> Find a brief summary at https://stackoverflow.com/a/52373592/1431016 and full details at https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher For JUnit 4.X it’s really: java -cp .:/usr/share/java/junit.jar org.junit.runner.JUnitCore [test class name] But if you are using JUnit 3.X note the class name is different: java -cp .:/usr/share/java/junit.jar junit.textui.TestRunner [test class name] You might need to … Read more

Unit testing private methods in C#

You can use the PrivateObject class: Class target = new Class(); PrivateObject obj = new PrivateObject(target); var retVal = obj.Invoke(“PrivateMethod”); Assert.AreEqual(expectedVal, retVal); Note: PrivateObject and PrivateType are not available for projects targeting netcoreapp2.0 – GitHub Issue 366

What’s the best strategy for unit-testing database-driven applications?

I’ve actually used your first approach with quite some success, but in a slightly different ways that I think would solve some of your problems: Keep the entire schema and scripts for creating it in source control so that anyone can create the current database schema after a check out. In addition, keep sample data … Read more

NUnit vs. MbUnit vs. MSTest vs. xUnit.net [closed]

I know this is an old thread, but I thought I’d post a vote for xUnit.NET. While most of the other testing frameworks mentioned are all pretty much the same, xUnit.NET has taken a pretty unique, modern, and flexible approach to unit testing. It changes terminology, so you no longer define TestFixtures and Tests…you specify … Read more

What does “DAMP not DRY” mean when talking about unit tests?

It’s a balance, not a contradiction DAMP and DRY are not contradictory, rather they balance two different aspects of a code’s maintainability. Maintainable code (code that is easy to change) is the ultimate goal here. DAMP (Descriptive And Meaningful Phrases) promotes the readability of the code. To maintain code, you first need to understand the … Read more