@@ -517,6 +517,53 @@ public async Task Converts_AspNet_health_check_results()
517517 """ ) ;
518518 }
519519
520+ [ Fact ]
521+ public async Task Can_skip_AspNet_health_check ( )
522+ {
523+ WebApplicationBuilder builder = TestWebApplicationBuilderFactory . Create ( ) ;
524+ builder . Configuration . AddInMemoryCollection ( AppSettings ) ;
525+ builder . Services . AddHealthActuator ( ) ;
526+
527+ IHealthChecksBuilder checksBuilder = builder . Services . AddHealthChecks ( ) ;
528+ checksBuilder . AddCheck < AspNetUnhealthyCheck > ( "aspnet-unhealthy-check" , tags : [ "SkipFromHealthActuator" ] ) ;
529+ checksBuilder . AddCheck < AspNetHealthyCheck > ( "aspnet-healthy-check" ) ;
530+
531+ await using WebApplication host = builder . Build ( ) ;
532+
533+ host . MapHealthChecks ( "/health" ) ;
534+ await host . StartAsync ( TestContext . Current . CancellationToken ) ;
535+ using HttpClient httpClient = host . GetTestClient ( ) ;
536+
537+ HttpResponseMessage actuatorResponse = await httpClient . GetAsync ( new Uri ( "http://localhost/actuator/health" ) , TestContext . Current . CancellationToken ) ;
538+
539+ actuatorResponse . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
540+
541+ string actuatorResponseBody = await actuatorResponse . Content . ReadAsStringAsync ( TestContext . Current . CancellationToken ) ;
542+
543+ actuatorResponseBody . Should ( ) . BeJson ( """
544+ {
545+ "status": "UP",
546+ "components": {
547+ "aspnet-healthy-check": {
548+ "status": "UP",
549+ "description": "healthy-description",
550+ "details": {
551+ "healthy-data-key": "healthy-data-value"
552+ }
553+ }
554+ }
555+ }
556+ """ ) ;
557+
558+ HttpResponseMessage aspNetResponse = await httpClient . GetAsync ( new Uri ( "http://localhost/health" ) , TestContext . Current . CancellationToken ) ;
559+
560+ aspNetResponse . StatusCode . Should ( ) . Be ( HttpStatusCode . ServiceUnavailable ) ;
561+
562+ string aspNetResponseBody = await aspNetResponse . Content . ReadAsStringAsync ( TestContext . Current . CancellationToken ) ;
563+
564+ aspNetResponseBody . Should ( ) . Be ( "Unhealthy" ) ;
565+ }
566+
520567 [ Fact ]
521568 public async Task Can_use_scoped_AspNet_health_check ( )
522569 {
0 commit comments