Cannot find symbol assertEquals

assertEquals is a static method. Since you can’t use static methods without importing them explicitly in a static way, you have to use either: import org.junit.Assert; … Assert.assertEquals(…) or: import static org.junit.Assert.assertEquals; … assertEquals(…) For @Test it’s a little bit different. @Test is an annotation as you can see by the @. Annotations are imported …

Read more

TDD and BDD Differences

I honestly don’t see the difference between BDD and TDD. That’s because there isn’t any. I mean, both are just tests if what is expected happens. That’s wrong. BDD and TDD have absolutely nothing whatsoever to do with testing. None. Nada. Zilch. Zip. Nix. Not in the slightest. Unfortunately, TDD has the word “test” in …

Read more

How do I test Rails migrations?

Peter Marklund has an example gist of testing a migration here: https://gist.github.com/700194 (in rspec). Note migrations have changed since his example to use instance methods instead of class methods. Here’s a summary: Create a migration as usual Create a file to put your migration test in. Suggestions: test/unit/import_legacy_devices_migration_test.rb or spec/migrations/import_legacy_devices_migration_spec.rb NOTE: you probably need to …

Read more

Mockito: given versus when

I assume you are talking about Mockito syntax. From my point of view these are just different styles. The first is the normal Mockito syntax and the second just tries to fit nicer into BDD style tests – I really like the second version because it reads so nicely in BDD tests.

How to run mocha and mocha-phantomjs tests from one “npm test” command in node.js?

I like the following: “scripts”: { “test”: “npm run test-node && npm run test-browser”, “test-node”: “mocha -R spec ./test/node/index.js”, “test-browser”: “mocha-phantomjs ./test/browser/index.html”} The && only runs the second if the first passes, and you can run either separately if you want. Note that npm always uses the relative mocha (inside node_modules), not the global one, …

Read more

Are there any provable real-world languages? (scala?)

Yes, there are languages designed for writing provably correct software. Some are even used in industry. Spark Ada is probably the most prominent example. I’ve talked to a few people at Praxis Critical Systems Limited who used it for code running on Boings (for engine monitoring) and it seems quite nice. (Here is a great …

Read more