Announce: significant-other package


#1

From the README…

Significant Other: An Atom Package

Provides a command to quickly switch between a source code file and its corresponding test file, and vice versa. Works with most project structures.

Supported project structures

Significant Other is intended to work automatically with popular project structures. It works with the project structure used in Rails projects, in Atom packages, in Ruby gems, and it will hopefully work for your project as well. To provide its functionality, Significant Other makes a few assumptions (listed below) about your project’s conventions.

Significant Other assumes that:

  • You want to toggle between a source file and the corresponding test file, or vice versa.
  • The source file and the test file start with the same name. The test file may include a suffix of _test, _spec, or -spec. For example, you can toggle between:
    • lib/profile.coffee and spec/profile.coffee
    • app/models/profile.rb and test/models/profile_test.rb
    • src/profile.js and src/profile_spec.js
    • profile.js and profile-spec.js
  • The source file and the test file have the same file extension. (I may consider removing this assumption at some point.)

If your project follows a well-defined, widely-used project structure that doesn’t satisfy the assumptions above, please let me know about it so that I can consider enhancing the package to support that project structure.

Installation

Using apm:

apm install significant-other

Or search for significant-other in the Atom Settings UI.

Bring your own keymap

You may want to use a keyboard shortcut for switching between source files and test files. This package does not provide a keyboard shortcut by default, but you can easily define your own. For example, if you wanted to use Control-., you’d add the following mapping to your ~/.atom/keymap.cson file:

'atom-workspace atom-text-editor:not(.mini)':
  'ctrl-.': 'significant-other:toggle'

TODO


#2

I love the package name.


#3

Could this also work with minified JavaScript and stylesheet files? e.g. script.min.js <-> script.js.


#4

That’s an interesting idea. It might be possible to use this package for that type of thing, but the package is specifically focused on navigating between a source code file and its corresponding test file. If you’re able to use the package to navigate between minified and non-minified JavaScript files, that would be a happy accident.


#5

I tried to use test-jumper package for that. Your seems a little bit more flexible, but still has hard-coded rules.
It would be nice if such package was able to:

  • get the location of source and test file roots from settings (assume at least same structure behind!)
  • use a pattern (ES6 template?) to generate the test file name from the source name (and back?). We like to prefix our test files with test, instead of postfixing, because in editors like Eclipse, we don’t want to see the test files when we start to type the class name. Or, on the reverse, get immediately the test files when we want to.
    Whatever the reasons, good or bad, I think such tool should adapt to the whims of its users… :smile:
    On Eclipse, precisely, the More Unit plugin allows this. (FYI)

And it brings me to another suggestion: add the capability to tweak settings per project (a .sorc or similar). Because structure we use at work are different from what I use (and it might vary depending on whim, language, etc.), or from of what I will find on this or that OSS project I work on.

Note: More Unit has even an additional lovely feature, that might not work in all languages / unit test forms (it is designed for JUnit family): if you switch while being on a method, it can find / guess the corresponding test method(s). Eg. from findTestMethod to testFindTestMethod, or it suggests between testFindTestMethod_found and testFindTestMethod_notFound.

Keep on the good work / good ideas.