Skip to content

Rule request: quick_discouraged_focused_test #1905

Closed
@ornithocoder

Description

It's quite common - in large test suites - the usage of focused test (fdescribe, fcontext, and fit), especially when doing TDD.

Focused test is a pretty handy feature, but not rarely do developers push code with focused test without realizing it :-(

This rule would trigger a warning for focused tests, to remind developers they have focused tests.

Non Triggering Examples

class TotoTests: QuickSpec {
   override func spec() {
       describe("foo") {
           describe("bar") { } 
           context("bar") {
               it("bar") { }
           }
           it("bar") { }
           itBehavesLike("bar")
       }
   }
}

Triggering Examples

class TotoTests: QuickSpec {
   override func spec() {
       fdescribe("foo") {
       }
   }
}
class TotoTests: QuickSpec {
   override func spec() {
       fcontext("foo") {
       }
   }
}
class TotoTests: QuickSpec {
   override func spec() {
       fit("foo") {
       }
   }
}
class TotoTests: QuickSpec {
   override func spec() {
       describe("foo") {
           fit("bar") { }
       }
   }
}
class TotoTests: QuickSpec {
   override func spec() {
       context("foo") {
           fit("bar") { }
       }
   }
}
class TotoTests: QuickSpec {
   override func spec() {
       describe("foo") {
           context("bar") {
               fit("toto") { }
            }
        }
    }
}
class TotoTests: QuickSpec {
   override func spec() {
       fitBehavesLike("foo")
   }
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions