পরীক্ষা চালানোর সময় আমার এক মভেন মডিউল আমার লগিং স্তরগুলিকে উপেক্ষা করে।
ইন src/test/resourcesআমার আছে application.properties:
app.name=bbsng-import-backend
app.description=Import Backend Module for Application
spring.profiles.active=test
# LOGGING
logging.level.root=error
logging.level.org.springframework.core =fatal
logging.level.org.springframework.beans=fatal
logging.level.org.springframework.context=fatal
logging.level.org.springframework.transaction=error
logging.level.org.springframework.test=error
logging.level.org.springframework.web=error
logging.level.org.hibernate=ERROR
আমিও চেষ্টা করেছি application-test.properties।
আমার অ্যাপ্লিকেশনটি প্রচুর লগ করে, বিশেষত প্রসঙ্গ লোড করার সময়। আমি চেষ্টা logback.xml, logback-test.xmlএবং logback-spring.xmlকিন্তু কিছুই করতে সাহায্য করে।
আমার পোম:
<parent>
<groupId>at.company.bbsng</groupId>
<artifactId>bbsng-import</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>bbsng-import-backend</artifactId>
<name>bbsng-import-backend</name>
<properties>
<start-class>at.company.bbsng.dataimport.ApplicationImportBackend</start-class>
</properties>
<dependencies>
<!-- APPLICATION ... -->
<dependency>
<groupId>at.company.bbsng</groupId>
<artifactId>bbsng-app-domain</artifactId>
<scope>test</scope>
</dependency>
<!-- SPRING ... -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>test</scope>
</dependency>
<!-- JAVAX ... -->
...
<!-- COMMONS ... -->
...
<!-- LOMBOK ... -->
...
<!-- DB -->
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${org.springframework.boot-version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
একটি সাধারণ টেস্ট ক্লাস:
@ContextConfiguration(classes = { ApplicationImportBackend.class })
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles({ "test" })
public class BatchJobConfigurationTests {
@Autowired
private JobLauncher jobLauncher;
@Test
public void testSimpleProperties() throws Exception {
assertNotNull(jobLauncher);
}
}
অ্যাপ্লিকেশন লগগুলি DEBUG মোডে রয়েছে।
এবং হ্যাঁ, application.propertiesলোড করা হবে। আমি ইতিমধ্যে ভুল কনফিগারেশনের মাধ্যমে অ্যাপ্লিকেশনটি ভাঙ্গার চেষ্টা করেছি।
কোন ইঙ্গিত জন্য আপনাকে ধন্যবাদ।
application.propertiesপরীক্ষার সূচনার চেয়ে পরে পার্স করা হচ্ছে। যে কারণেorg.springframework.testপ্রাথমিক পরীক্ষার লগিংয়ের কোনও প্রভাব নেই।