Skip to content

Commit

Permalink
Introduce @⁠Disabled AOT tests for @⁠TestBean support
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Sep 16, 2024
1 parent d3755ab commit 31a6e98
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,25 @@ void endToEndTestsForEntireSpringTestModule() {
runEndToEndTests(testClasses, false);
}

@Disabled("Comment out to run @TestBean integration tests in AOT mode")
@Test
void endToEndTestsForTestBeanOverrideTestClasses() {
List<Class<?>> testClasses = List.of(
org.springframework.test.context.aot.samples.bean.override.convention.TestBeanJupiterTests.class,
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.class,
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.TestBeanFieldInEnclosingClassTests.class,
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.TestBeanFieldInEnclosingClassTests.TestBeanFieldInEnclosingClassLevel2Tests.class,
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.TestBeanFactoryMethodInEnclosingClassTests.class,
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.TestBeanFactoryMethodInEnclosingClassTests.TestBeanFactoryMethodInEnclosingClassLevel2Tests.class
);

runEndToEndTests(testClasses, true);
}

@Disabled("Comment out to run selected integration tests in AOT mode")
@Test
void endToEndTestsForSelectedTestClasses() {
List<Class<?>> testClasses = List.of(
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.class,
org.springframework.test.context.bean.override.mockito.MockitoBeanForByNameLookupIntegrationTests.class,
org.springframework.test.context.junit4.SpringJUnit4ClassRunnerAppCtxTests.class,
org.springframework.test.context.junit4.ParameterizedDependencyInjectionTests.class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.test.context.aot.samples.bean.override.convention;

import org.junit.jupiter.api.Test;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.bean.override.convention.TestBean;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author Sam Brannen
* @since 6.2
*/
@SpringJUnitConfig
public class TestBeanJupiterTests {

@TestBean
String magicBean;

static String magicBean() {
return "enigma-override";
}

@Test
void tests() {
assertThat(magicBean).isEqualTo("enigma-override");
}

@Configuration(proxyBeanMethods = false)
static class Config {

@Bean
String magicBean() {
return "enigma";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void fieldWithMethodNameHasOverride(ApplicationContext ctx) {

@Nested
@DisplayName("With @TestBean in the enclosing class of the enclosing class")
class TestBeanFieldInEnclosingClassLevel2Tests {
public class TestBeanFieldInEnclosingClassLevel2Tests {

@Test
void fieldHasOverride(ApplicationContext ctx) {
Expand All @@ -130,7 +130,7 @@ void fieldWithMethodNameHasOverride(ApplicationContext ctx) {

@Nested
@DisplayName("With factory method in enclosing class")
class TestBeanFactoryMethodInEnclosingClassTests {
public class TestBeanFactoryMethodInEnclosingClassTests {

@TestBean(methodName = "nestedField", name = "nestedField")
String nestedField2;
Expand All @@ -143,7 +143,7 @@ void fieldHasOverride(ApplicationContext ctx) {

@Nested
@DisplayName("With factory method in the enclosing class of the enclosing class")
class TestBeanFactoryMethodInEnclosingClassLevel2Tests {
public class TestBeanFactoryMethodInEnclosingClassLevel2Tests {

@TestBean(methodName = "nestedField", name = "nestedField")
String nestedField2;
Expand Down

0 comments on commit 31a6e98

Please sign in to comment.