Skip to content

User Guide


pip install nimoy-framework


Let's create your first spec!

Project Structure

Within your project directory create a specs directory:

+-- mymodule/
+-- specs/              <-- Added a new folder for the specifications
+-- index.html 

Nimoy Modules

Ideally every one of your Python modules may be represented by a Nimoy module, so you can mimic your application's directory structure within the specs folder.

Within the specs folder create a new module named

Note: Nimoy will only pick up on modules ending with

+-- mymodule/
+-- specs/
    +-- <-- Added a new folder for the specifications
+-- index.html 

Your First Specification

To be considered as a specification, your class must end with the name Spec and must extend the Specification class.

Any public method within the specification class will be treated as a feature method.


from nimoy.specification import Specification

# The class name ends with Spec and extends Specification
class MyFirstSpec(Specification):

    # The feature method is public
    def my_feature_method(self):
        with given:
            a = 'The quick brown fox'
        with expect:
            a == 'The quick frown box'

    # This is not a feature method
    def _helper_method(self):

Running Your Specification

Simply execute nimoy within your project directory. Nimoy will auto-discover all your specs!

$ nimoy

my_feature_method (builtins.MyFirstSpec) ... FAIL

FAIL: my_feature_method (builtins.MySpec)
Expected: 'The quick frown box'
     but: was 'The quick brown fox'
- The quick brown fox
?           ^     ^

+ The quick frown box
?           ^     ^

Ran 1 test in 0.002s

FAILED (failures=1)

Running Nimoy

Run All

By default, Nimoy will run all the specifications in the current directory and in any child directory:

$ nimoy

Run Some

You can tell Nimoy to run the specifications in certain directories:

$ nimoy subdir-1 subdir-2

Run Just

Nimoy can run specific modules:

$ nimoy subdir-1/ subdir-2/

Or certain specifications:

$ nimoy subdir-1/ subdir-2/

And even specific features:

$ nimoy subdir-1/ subdir-2/