{"id":29134088,"url":"https://github.com/fabric8io/kubernetes-assertions","last_synced_at":"2026-03-10T02:32:39.320Z","repository":{"id":40918486,"uuid":"242104834","full_name":"fabric8io/kubernetes-assertions","owner":"fabric8io","description":"This library provides a bunch of helpful assertj assertions for working with the kubernetes-api","archived":false,"fork":false,"pushed_at":"2022-06-22T20:10:06.000Z","size":138807,"stargazers_count":10,"open_issues_count":2,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2026-01-13T19:48:15.138Z","etag":null,"topics":["assertj","kubernetes","kubernetes-assertions","openshift"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabric8io.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-21T09:42:48.000Z","updated_at":"2023-03-31T10:18:41.000Z","dependencies_parsed_at":"2022-08-29T04:50:38.328Z","dependency_job_id":null,"html_url":"https://github.com/fabric8io/kubernetes-assertions","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fabric8io/kubernetes-assertions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabric8io%2Fkubernetes-assertions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabric8io%2Fkubernetes-assertions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabric8io%2Fkubernetes-assertions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabric8io%2Fkubernetes-assertions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabric8io","download_url":"https://codeload.github.com/fabric8io/kubernetes-assertions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabric8io%2Fkubernetes-assertions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30322645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T01:36:58.598Z","status":"online","status_checked_at":"2026-03-10T02:00:06.579Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertj","kubernetes","kubernetes-assertions","openshift"],"created_at":"2025-06-30T08:13:08.431Z","updated_at":"2026-03-10T02:32:39.281Z","avatar_url":"https://github.com/fabric8io.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Kubernetes Assertions\n\n[![CircleCI](https://circleci.com/gh/fabric8io/kubernetes-assertions.svg?style=svg)](https://circleci.com/gh/fabric8io/kubernetes-assertions)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.fabric8/kubernetes-assertions/badge.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/io.fabric8/kubernetes-assertions/)\n[![Javadocs](http://www.javadoc.io/badge/io.fabric8/kubernetes-assertions.svg?color=blue)](http://www.javadoc.io/doc/io.fabric8/kubernetes-assertions)\n\nThis library provides a bunch of helpful [assertj](http://joel-costigliola.github.io/assertj/) assertions for working with the [kubernetes-api](https://github.com/fabric8io/fabric8/tree/master/components/kubernetes-api).\n\n### Default system test\n\nThe following code provides a default system test:\n\n```\n             assertThat(client).deployments().pods().isPodReadyForPeriod();\n```\n\nThis will assert that the current project's `Deployment` creates at least one pod; that it becomes `Ready` within a time period (30 seconds by default), then that the pod keeps being `Ready` for a period (defaults to 10 seconds).\n\nThis may seem a fairly simple test case; but it catches most errors with the `Deployment` being invalid or failing to start; the pod starting then failing due to some configuration issue etc.\n\nIf your application uses [liveness checks](http://kubernetes.io/docs/user-guide/liveness/) (which are used by default with Spring Boot apps) then this test also asserts that the liveness checks keep valid for the period too. So if your application fails to connect to a database or your Camel route fails to start a route or whatever; then the test fails!\n\nThis means to improve your system tests you can just improve your liveness checks; which also helps Kubernetes manage your production environment too!\n\n### Other examples\n\nSome quick examples:\n\n* [assertThat(KubernetesClient)](https://github.com/fabric8io/fabric8/blob/master/components/kubernetes-assertions/src/test/java/io/fabric8/kubernetes/assertions/Example.java#L38) helper code that is available if you add the **kubernetes-assertions** dependency.\n* [assertThat(Pod)](https://github.com/fabric8io/fabric8/blob/master/components/kubernetes-assertions/src/test/java/io/fabric8/kubernetes/assertions/ExampleTest.java#L49-L50) and navigating the model \n* [assertThat(PodList)](https://github.com/fabric8io/fabric8/blob/master/components/kubernetes-assertions/src/test/java/io/fabric8/kubernetes/assertions/ExampleTest.java#L96-L102) using list navigations\n\n### Navigating and asserting around resources\n\nWhen working with Kubernetes and OpenShift resources in test cases you'll find that objects can be massively nested. \n\nFor example even using something as simple as a Pod you need to navigate to compare its name:\n\n```java\nPod pod = kubernetesClient.pods().inNamespace(ns).withName(\"foo\").get();\nassertThat(pod).metadata().name().isEqualTo(\"foo\");\n```\n\nThings get even more complex when asserting a ReplicationController\n\n```java\nReplicationController rc = kubernetesClient.replicationControllers().inNamespace(ns).withName(\"foo\").get();\nassertThat(rc).spec().template().spec().containers().first().image().isEqualTo(\"someDockerImageName\");\n```\n\nWhats great about Kubernetes Assertions is that you can chain methods together to navigate the model; if any navigation fails you get meaninful errors in the test failure telling you exactly which object was null or list was empty or other assertion failed (e.g. a list index was out of range) etc.\n\nFor example here's some example error messages from assertj when navigation or assertions fail in [these tests](https://github.com/fabric8io/fabric8/blob/master/components/kubernetes-assertions/src/test/java/io/fabric8/kubernetes/assertions/ExampleTest.java#L111-L123):\n\n```\n    org.junit.ComparisonFailure: [podListWith2Items.items.first().metadata.name] expected:\u003c\"[shouldNotMatch]\"\u003e but was:\u003c\"[abc]\"\u003e\n    \n    java.lang.AssertionError: [podListWith2Items.items.index]\n    Expecting:\n     \u003c-1\u003e\n    to be greater than or equal to:\n     \u003c0\u003e\n```\n                                \n### Add it to your Maven pom.xml\n\nTo be able to use the Java code in your [Apache Maven](http://maven.apache.org/) based project add this into your pom.xml\n\n            \u003cdependency\u003e\n                \u003cgroupId\u003eio.fabric8\u003c/groupId\u003e\n                \u003cartifactId\u003ekubernetes-assertions\u003c/artifactId\u003e\n                \u003cversion\u003e4.0.0\u003c/version\u003e\n                \u003cscope\u003etest\u003c/scope\u003e\n            \u003c/dependency\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabric8io%2Fkubernetes-assertions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabric8io%2Fkubernetes-assertions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabric8io%2Fkubernetes-assertions/lists"}