GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — UtUtils methods using setAccessible doesn't work in Java 17 · Issue #2026 · UnitTestBot/UTBotJava Open Labels comp-codegenIssue is related to code generatorIssue is related to code generatorctg-bugIssue is a bugIssue is a bug DescriptionDescription UtUtils methods using setAccessible doesn't work in Java 17 To Reproduce
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.36</version> </dependency>
Expected behavior Tests classified as Successful should pass. Actual behavior 3 successful executions generated by Symbolic engine - fail. java.lang.reflect.InaccessibleObjectException: Unable to make private native java.lang.reflect.Field[] java.lang.Class.getDeclaredFields0(boolean) accessible: module java.base does not "opens java.lang" to unnamed module @5afa04c Visual proofs (screenshots, logs, images) @Test @DisplayName("loggerUsage: -> return 2") public void testLoggerUsage_Return2() throws ClassNotFoundException, IllegalAccessException, NoSuchFieldException { org.mockito.MockedStatic mockedStatic = null; try { Class loggerExampleClazz = Class.forName("org.utbot.examples.mixed.LoggerExample"); Logger prevLogger = ((Logger) getStaticFieldValue(loggerExampleClazz, "logger")); try { Logger loggerMock = mock(Logger.class); (when(loggerMock.isDebugEnabled())).thenReturn(false); setStaticField(loggerExampleClazz, "logger", loggerMock); mockedStatic = mockStatic(org.slf4j.LoggerFactory.class); (mockedStatic.when(() -> org.slf4j.LoggerFactory.getLogger(any(Class.class)))).thenReturn(loggerMock); LoggerExample loggerExample = new LoggerExample(); int actual = loggerExample.loggerUsage(); assertEquals(2, actual); } finally { setStaticField(LoggerExample.class, "logger", prevLogger); } } finally { mockedStatic.close(); } } Environment IntelliJ IDEA 2022.3.3 Ultimate Additional context The same tests generated in UTBotJava project pass. When the following keys are added to the test run configuration in the new project - the tests pass. Activity
MetadataMetadataAssigneesLabelscomp-codegenIssue is related to code generatorIssue is related to code generatorctg-bugIssue is a bugIssue is a bug TypeProjects
MilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |