Skip to content

Improve linter testing #2250

Closed
Closed
@bdovaz

Description

@bdovaz

Conversation comes from #2244

Hypothesis is a phenomenal property-based testing library for Python, but we're a ways off from that today.

Originally posted by @Kurt-von-Laven in #2244 (comment)

Hypothesis is a phenomenal property-based testing library for Python, but we're a ways off from that today.

But we are testing that our wrapping code and calling the linter works, not testing the linter itself. As everyone, learning to better QA software is always a good thing. It's always a weak spot.

Originally posted by @echoix in #2244 (comment)

Hypothesis can help with that too, but it's rarely the case that one would want to write all tests exclusively in Hypothesis. Property-based testing is intended to be used in conjunction with conventional example-based testing.

Originally posted by @Kurt-von-Laven in #2244 (comment)

Right now classes are automatically generated through:

https://github.com/oxsecurity/megalinter/blob/main/.automation/build.py#L644

The generated classes are here:

https://github.com/oxsecurity/megalinter/tree/main/megalinter/tests/test_megalinter/linters

They all inherit from the next class so all linters have exactly the same tests:

https://github.com/oxsecurity/megalinter/blob/main/megalinter/tests/test_megalinter/LinterTestRoot.py#L11

This class uses this utility class:

https://github.com/oxsecurity/megalinter/blob/main/megalinter/tests/test_megalinter/helpers/utilstest.py

And the input for the tests is here:

https://github.com/oxsecurity/megalinter/tree/main/.automation/test

The problem I see as I said, among other things, is that there are no specific tests for certain linters that can apply fixes or format files. Right now there is no testing of any of this.

This class does the trick but we would have to think of a system applicable to all linters:

https://github.com/oxsecurity/megalinter/blob/main/megalinter/tests/test_megalinter/mega_linter_2_fixes_test.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions