diff --git a/test/e2e/karmadactl_test.go b/test/e2e/karmadactl_test.go index fd61e336dc17..d201ee134308 100644 --- a/test/e2e/karmadactl_test.go +++ b/test/e2e/karmadactl_test.go @@ -546,7 +546,8 @@ var _ = ginkgo.Describe("Karmadactl top testing", func() { for _, clusterName := range framework.ClusterNames() { cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, "", karmadactlTimeout, "top", "pod", podName, "-n", testNamespace, "-C", clusterName) _, err := cmd.ExecOrDie() - gomega.Expect(strings.Contains(err.Error(), fmt.Sprintf("pods \"%s\" not found", podName))).To(gomega.BeTrue(), "should not found") + gomega.Expect(err).Should(gomega.HaveOccurred()) + gomega.Expect(strings.Contains(err.Error(), fmt.Sprintf("pods \"%s\" not found", podName))).To(gomega.BeTrue(), "should not found", fmt.Sprintf("errMsg: %s", err.Error())) } }) })