scala-ide/scala-ide — pull request #680 by sschaef (2014-04-25 16:27:18+00:00)
Title: New test suite for code completion / text edits

This PR took me about a week full time work and while I can't remember where all the time went into, the result is simply awesome (at least in my opinion ;)).

The new tests look like this:

```scala
"""
class A {
def foo(i: Int) = 0
}
object X {
(new A).fo^
}
""" becomes """
class A {
def foo(i: Int) = 0
}
object X {
(new A).foo([[i]])^
}
""" after Completion("foo(Int): Int")
```

It is so beautiful, I could go and make art out of it. The design goals were:

- Only touch one file to write a test. No need to create files in the test-workspace anymore.
- Tests should be easy to write. For text edit tests it turned out a declarative approach, which works with multi-line strings and a nice DSL, can hold this requirement.
- Tests should test everything. For example for the completion tests this means not only the found completions are tested, but also the document after the completion is applied.

With the refactorings done in this PR the way is open for a rewrite of other test suites, which includes the rest of the completion tests, the quick fix tests and everything else that needs to touch source code. The refactorings split up the code in UI and non UI logic, which was necessary to get the new tests to work.

With the merge of this PR the time is over where one can say that a new feature that allows users to change source code automatically has to be merged without tests because of no easy way to write them. I included some new tests especially for the completion overwrite feature but overall the commits of this PR should not introduce functional changes to the IDE. If they do then they are minor and documented in the commit messages (otherwise it is a bug).

---

Because all tests are entirely generated at runtime, there are still some limitations, which I hopefully will fix when I write more tests and new features that need them. The limitations include a non existing way to (easily/declaratively) create multiple files with only one test and a correct mapping of packages to directory hierarchy.
For now these limitations prevented me of moving all existing code completion tests to the new test suite (and I lost motivation in moving more tests - I have to do something else in the meantime ;)).

Furthermore this PR is still a little bit broken. It suffers from the problem I mentioned on the mailings lists [some days ago](https://groups.google.com/forum/#!topic/scala-ide-dev/i3tJSpox0lI) and there are also some tests that spuriously fail on my system (including old and new code completion tests), which is annoying because entering the debugger means the tests run fine. Hopefully that is just another "failed to wait long enough on scalac" issue. I assume @dragos can tell me more about this (once you're back from the dead of course ;)).

---

Now, given that my GSoC Proposal is accepted I consider this PR as the "official" start of my GSoC work period (because I have in mind to build upon this PR with my later work) where even more awesome PRs will follow.

I'm awaiting your ideas and suggestions to make this PR even better.