Cobertura检查Travis CI失败

时间:2016-03-07 11:40:35

标签: java maven travis-ci cobertura maven-cobertura-plugin

在我的Maven构建中,我使用Cobertura检查是否存在一定的最小覆盖率:

public void showNotificationMessage(String title, String message, Intent intent) {

        if (TextUtils.isEmpty(message))
            return;

        int icon = R.drawable.ic_launcher;

        int mNotificationId = new Random().nextInt(5000);

        PendingIntent resultPendingIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
        Notification notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
                .setAutoCancel(true)
                .setContentTitle(title)
                .setStyle(inboxStyle)
                .setContentIntent(resultPendingIntent)
                .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
//                .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
                .setContentText(message)
                .build();

        NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(mNotificationId, notification);
    }

运行<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.5.2</version> <configuration> <check> <branchRate>100</branchRate> </check> </configuration> <executions> <execution> <goals> <goal>cobertura</goal> <goal>check</goal> </goals> </execution> </executions> </plugin> 时,这很好用。但是,在Travis CI中,构建失败,因为Travis first runs mvn install获取依赖项。显然,当跳过测试时,没有覆盖,因此整个构建失败:

mvn install -DskipTests=true

我可以以某种方式配置Cobertura跳过检查是否跳过测试?或者是否还有其他解决方案,也许是特拉维斯方面?

这是我的[ERROR] ch.trick17.betterchecks.fluent.StringCheck failed check. Branch coverage rate of 0.0% is below 100.0% ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ ... [ERROR] Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.5.2:check (default) on project better-checks-core: Coverage check failed. See messages above. -> [Help 1] 文件:

.travis.yml

2 个答案:

答案 0 :(得分:0)

您可以使用:install: true which skips the install step来转换它。

答案 1 :(得分:0)

作为kmarbaise答案的替代方案,您可以替换自定义它,而不是完全关闭安装步骤design decision

install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dcobertura.skip=true -B -V

这样,实际构建脚本的输出不会因下载依赖项和Maven插件的输出而混乱。