Skip to content

Commit b83a4f6

Browse files
add test
1 parent 78f56a0 commit b83a4f6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.example.batch;
2+
3+
import static org.junit.jupiter.api.Assertions.*;
4+
import static org.mockito.Mockito.*;
5+
6+
import org.junit.jupiter.api.Test;
7+
import org.springframework.boot.test.context.SpringBootTest;
8+
import org.springframework.test.context.TestPropertySource;
9+
10+
@SpringBootTest
11+
@TestPropertySource(
12+
properties = {
13+
"spring.batch.job.enabled=false",
14+
"spring.datasource.mysqlmain.url=jdbc:mysql://localhost:3306/sampledb",
15+
"spring.datasource.mysqlmain.username=sampleuser",
16+
"spring.datasource.mysqlmain.password=samplepassword"
17+
})
18+
class DbAndCsvBatchAppTest {
19+
20+
@Test
21+
void testMainMethod() {
22+
// Arrange
23+
String[] args = {"--spring.batch.job.name=DB_TO_CSV", "--spring.profiles.active=local"};
24+
System.setProperty("sun.java.command", String.join(" ", args));
25+
26+
// Act
27+
DbAndCsvBatchApp.main(args);
28+
29+
// Assert
30+
// Main method execution doesn't throw exceptions
31+
}
32+
}

0 commit comments

Comments
 (0)