排除PIT执行的测试

时间:2018-01-27 01:58:47

标签: java maven unit-testing mutation-testing pitest

我必须将我的集成测试从PIT的执行中排除。自版本1.3.0起,有一个选项excludedTestClasses。我试图通过以下PIT Maven插件的配置来传递这些测试。

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>1.3.1</version>
    <configuration>
        <verbose>true</verbose>
        <mutationThreshold>80</mutationThreshold>
        <targetClasses>
            <param>de.comp.proj.*</param>
        </targetClasses>
        <excludedTestClasses>
            <param>**/*IT.java</param>
        </excludedTestClasses>
    </configuration>
 </plugin>

然而,PIT仍然使用后缀IT执行所有测试。我看了看源头但是在晚上迷路了; - )

那么,我怎样才能跳过集成测试呢?

4 个答案:

答案 0 :(得分:3)

PIT过滤器与已编译二进制文件中的类名匹配,而不是与源文件名匹配。

您的过滤器应该类似于

<excludedTestClasses>
    <param>de.comp.**.*IT</param>
</excludedTestClasses>    

de.comp.*IT排除了包de.comp中的所有测试。使用de.comp.**.*IT子包中的所有测试也会被忽略。

答案 1 :(得分:3)

我使用pitest-maven版本1.4.2。

此配置对我来说很好:

  func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    let annotation = annotation as? Anno
        let identifier = "userAnnotation"
        let view: MKAnnotationView

        view = MKAnnotationView(annotation: annotation, reuseIdentifier: identifier)
        // Get a reference to the storage service using the default Firebase App
        let storage = Storage.storage()

        // Create a storage reference
        let storageRef = storage.reference()

        //points to the child directory where the profile picture will be saved on firebase
        let profileImageRef = storageRef.child("/User Profile Pictures/"+(user?.uid)!+"/profile_pic.jpg")
        if (GIDSignIn.sharedInstance().currentUser != nil) {


            let imageUrl = GIDSignIn.sharedInstance().currentUser.profile.imageURL(withDimension: 400).absoluteString
            let url  = NSURL(string: imageUrl)! as URL
            let data = NSData(contentsOf: url)

            //upload image to storage
            _ = profileImageRef.putData(data! as Data, metadata: nil) { (metadata, error) in
                guard let metadata = metadata else {
                    // Uh-oh, an error occurred!
                    return
                }
                // Metadata contains file metadata such as size, content-type, and download URL.
                let size = metadata.size
                print(size)
                // You can also access to download URL after upload.
                storageRef.downloadURL { (url, error) in
                    guard let downloadURL = url else {
                        // Uh-oh, an error occurred!
                        return
                    }
                    print(downloadURL)
                }

            }


            let pinPic = UIImage(data: data! as Data)
            view.image = pinPic

        }
        return view

    }

也许以下语法适用于pitest-maven的旧​​版本:

<excludedTestClasses>          
  <excludedTestClass>de.com.**.*IT</excludedTestClass>
</excludedTestClasses>

答案 2 :(得分:3)

对于使用Gradle插件的人:

pitest {
    excludedTestClasses = ['de.comp.**.*IT']
}

答案 3 :(得分:0)

对于使用Gradle插件的人:

请参阅配置:http://pitest.org/quickstart/commandline/

pitest {
    excludedClasses = ['de.comp.**.*IT']
}