delayed-assert
delayed-assert copied to clipboard
Is it necessary to have the word "test" in the function name
As the title says. Our tests are written with Behave and our step names do not include the word "test". Is this requirement necessary?
With the current implementation, the test method must start with test
. Otherwise, the library has no way to identify whether the assertion failure originated from a root test method or a method called from a test method.
eg.
def test_method(arg):
steps of the test
delayed_assert.expect(3 == 1)
delayed_assert.assert_expectations()
vs
def test_method(arg):
steps of the test
some_method()
def make_assertion()
delayed_assert.expect(3 == 1)
delayed_assert.assert_expectations()
That's how the current implementation detects the top-level test method name.
Additionally, when the tests are executed in parallel. This check ensures the stack traces are attached to the correct test method. https://github.com/pr4bh4sh/delayed-assert/blob/master/delayed_assert/delayed_assert.py#L92
Now to the solution, If you have a specific pattern for the test method name. A prefix or suffix on the test method name. I can make some changes to make it configurable.
We don't have a pattern for that. Step names are based on the Gherkin syntax so it's obvious which step is mapped to which function in the logs. It's not a big deal to add "test" at the end it's just inconsistent. Thank for the reply. The tool is great.
I'm glad to hear that this library is useful for you.
I don't have any experience with working Behave and at the moment I'm not using this library for anything I'm working on. Just maintaining and adding features based on the issues raised here at Github.
However, If you could send me a small demo project with Behave using this library and with instructions to execute it. just one dummy test would be sufficient. I can check what can I do to tweak the library to improve, sometimes over the weekend.
Up to you though, if you are happy with what it does right now all good.