Jasmine is a nice unit testing framework for JavaScript. It not only tests your code, it provides a nice way to document it by:
I'm wondering if anything comparable exists for C# and/or Java.
Sample Code. Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.
Jasmine is an open-source testing framework for JavaScript. It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec.
The current home page of Jasmine says that it's “a behavior-driven development framework for testing JavaScript code.” So the intent of Jasmine is to be a BDD testing framework, per its authors. So, while the authors of Jasmine have intended it as a BDD testing framework, it can also be used with TDD and unit testing.
I just came across NJasmine on GitHub. I've never used it but thought this might help others like myself that want the awesome of Jasamine in C# unit tests.
From the GitHub:
NJasmine is a RSpec-ish test language inspired by the javascript test library Jasmine (https://github.com/fschwiet/DreamNJasmine) for C# / .Net programming.
given("some preconditions", () => {
var range = 10;
when("the system under test is ran", () => {
var sut = new SystemUnderTest();
bool score = arrange(() => sut.Fire(range));
then("win!", () => {
expect(() => score);
});
});
});
Available on Nuget: http://nuget.org/List/Packages/NJasmine
Again, I can't vouch for this as I haven't used it, but I hope this will help others make informed decisions.
HTH
Oleaster is a Java testing framework with clean simple syntax, extensively using Java 8 arrow functions. It is executed using JUnit runner.
Code sample from hompage:
@RunWith(OleasterRunner.class)
public class OleasterIntroductionTest {{
describe("A suite", () -> {
it("contains a spec with an expectation", () -> {
expect(40 + 2).toEqual(42);
});
});
}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With