Test Runner Timings

salesforce

#1

Hi guys,

Been using Cloud9 for a few months now. Haven’t used sublime or Eclipse since :expressionless:

I have a minor issue with the test runner - not sure if this is a settings thing, or a bug.

When you save an apex class, Cloud9 detects which tests should be re-run and runs them. This is great.

The issue I’m having is that quite often, the test classes are fired before the save is complete. On less complex orgs, this means that the tests essentially run against the old version of the file.

It may because I use TDD that I’m the only one coming across this issue, because I regularly write failing tests and then expect them to pass when I hit save.

I’m quite often finding myself doing this:

  1. Update some code
  2. Hit save
  3. Before save completes, tests run on old code base (before I had fixed the code for the test to pass)
  4. Twiddle my thumbs while the tests run
  5. Test Fails
  6. Manually run the test (without any further changes). Because the apex class is now synced, the tests pass

Is it possible to delay the test running until after the files have definitely synced?

I’ve also noticed that the tests execute even if the file doesn’t save properly (such as if there’s a syntax error).

The slightly annoying workflow described above has led to me disable the auto test runner. This makes me sad, because it is actually one of my favourite features.


#2

Hey Chris,

Props for your adoption of TDD! I also write my code that way. I’ve noticed the same thing which is why I typcially run the tests manually. Something you can try is the force.com cli which is built in to the terminal. You can type “force test all” or “force test [test class name]” into the terminal and it’s very fast.

The test runner is still experimental and it looks like you’ve found a bug. @bradydowling: could you please check this out and verify? When the test classes run they should always run with the latest changes; meaning that if there is a save and then auto run, the save operation should complete first, and then the tests should run.


#3

Hi Jeff,

Is there another way to write code? :relaxed:

That’s the workaround I’m using at the moment - just disabling the runner and manually running the tests. It’s still pretty easy, but thought I’d report the issue.

I also have a couple of other minor issues with it if you’re interested:

  • I accidentally removed a test from the test runner by right clicking and selecting “remove” (yes, I know that makes me a bit stupid). There doesn’t appear to be a way to add tests back in to the test runner. Opening the file and saving adds it back in temporarily, but it doesn’t pick up and new tests unless I refresh the browser and re-save the file.

  • I also don’t seem to be able to switch off code coverage. I’ve switched off the “always run with code coverage” option, but sometimes when I run tests it still gives me the green/red highlighting across my code. This is great when I want to view code coverage, but generally speaking it just makes the code hard to read if I’m not actively looking at coverage.

Other than that, I’m really enjoying using Cloud9 IDE. Props to the team!


#4

Chris,

I think this menu might help you out. As for removing and re-adding a test, I’ve not done that before. Perhaps the refresh command in this screenshot?