Skip to content

Conversation

@marijarin
Copy link
Collaborator

@marijarin marijarin commented May 3, 2025

Closes #231

Привет! Я исправила проблему с нахождением логов в тестах, соответствующих регулярному выражению для Котлин-модуля.
Осталась такая проблема: если я добавляю зависимость implementation("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.6"), то в тестах не используется нужный логгер, появляется ошибка
java.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@752ffce3 testClass = io.github.mfvanek.spring.boot3.kotlin.test.ActuatorEndpointTest, locations = [], classes = [io.github.mfvanek.spring.boot3.kotlin.test.Application], contextInitializerClasses = [io.github.mfvanek.spring.boot3.kotlin.test.support.KafkaInitializer, io.github.mfvanek.spring.boot3.kotlin.test.support.JaegerInitializer, io.github.mfvanek.spring.boot3.kotlin.test.support.PostgresInitializer], activeProfiles = ["test"], propertySourceDescriptors = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true", "server.port=0"], contextCustomizers = [org.springframework.boot.test.autoconfigure.OnFailureConditionReportContextCustomizerFactory$OnFailureConditionReportContextCustomizer@38cedb7d, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@b36f3982, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@9fdfac6d, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@611640f0, [ImportsContextCustomizer@5b86f4cb key = [org.springframework.cloud.contract.wiremock.WireMockRestTemplateConfiguration, org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration, org.springframework.cloud.contract.wiremock.WireMockConfiguration, org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration, org.springframework.boot.actuate.autoconfigure.tracing.MicrometerTracingAutoConfiguration, org.springframework.boot.actuate.autoconfigure.tracing.NoopTracerAutoConfiguration, org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration, org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@73aeef7d, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@4d9754a8, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@4d84049a, org.springframework.boot.test.web.reactive.server.WebTestClientContextCustomizer@4cb702ce, org.springframework.boot.test.web.reactor.netty.DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory$DisableReactorResourceFactoryGlobalResourcesContextCustomizerCustomizer@4f654cee, org.springframework.test.context.support.DynamicPropertiesContextCustomizer@0, org.springframework.boot.test.context.SpringBootTestAnnotation@c9233230], resourceBasePath = "src/main/webapp", contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:180) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:130) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:155) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:111) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:260) at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:160) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at java.base/java.util.Optional.orElseGet(Optional.java:364) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.helpers.NOPLoggerFactory loaded from file:/C:/Users/m.zharinova/.gradle/caches/modules-2/files-2.1/io.gitlab.arturbosch.detekt/detekt-formatting/1.23.6/48c928585b597774c77a23291f5fd34f24fb99a1/detekt-formatting-1.23.6.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.helpers.NOPLoggerFactory at org.springframework.util.Assert.instanceCheckFailed(Assert.java:618) at org.springframework.util.Assert.isInstanceOf(Assert.java:533) ...
Я исключала модуль slf4j и другие зависимости внутри io.gitlab.arturbosch.detekt:detekt-formatting:1.23.6, но не помогло.

Также есть проблема с jacoco. Хотя тестов не меньше, чем в java-модуле, не проходит верификация, я так понимаю от того. что логгеры вне класса. Я сами логгеры и fun main исключила из проверок jacoco, но методы, где используются эти логгеры, помечены, как недостаточно покрытые тестами, хотя в java-модуле этого нет. Пока не придумала, как это поправить.
Вот так в Котлин-классе
image

Вот так в аналогичном java-классе
image

Сначала я начала добавлять еще тесты, но подумала, может, есть другой способ, не тесты ради покрытия.

Copy link
Owner

@mfvanek mfvanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно взять более новую версию detekt

@marijarin
Copy link
Collaborator Author

Не поправила пока только вынесение версии java в константу, т.к. сейчас там используются енамы, надо посмотреть, как их обобщить везде

@codecov
Copy link

codecov bot commented May 7, 2025

Codecov Report

Attention: Patch coverage is 97.52066% with 3 lines in your changes missing coverage. Please review.

Project coverage is 93.46%. Comparing base (8edd8a1) to head (219c051).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ng/boot3/kotlin/test/controllers/TimeController.kt 93.33% 0 Missing and 1 partial ⚠️
...lin/test/filters/TraceIdInResponseServletFilter.kt 87.50% 0 Missing and 1 partial ⚠️
...g/boot3/kotlin/test/service/KafkaReadingService.kt 95.23% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #264      +/-   ##
============================================
+ Coverage     90.81%   93.46%   +2.65%     
- Complexity       59      102      +43     
============================================
  Files            25       39      +14     
  Lines           185      306     +121     
  Branches          6       10       +4     
============================================
+ Hits            168      286     +118     
  Misses           14       14              
- Partials          3        6       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@mfvanek mfvanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detekt был подключен некорректно. Я это исправил.

Теперь нужно поправить все предупреждения от detekt

@mfvanek mfvanek changed the title Issue 231 Add Kotlin app with Spring Boot 3 and coroutines May 17, 2025
@mfvanek mfvanek merged commit b971b1e into master May 18, 2025
3 checks passed
@mfvanek mfvanek deleted the issue-231 branch May 18, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Kotlin app with Spring Boot 3 and coroutines

3 participants