Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
KTC-YoheiMiyashita committed Dec 24, 2024
1 parent 78f56a0 commit b83a4f6
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.batch;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;

@SpringBootTest
@TestPropertySource(
properties = {
"spring.batch.job.enabled=false",
"spring.datasource.mysqlmain.url=jdbc:mysql://localhost:3306/sampledb",
"spring.datasource.mysqlmain.username=sampleuser",
"spring.datasource.mysqlmain.password=samplepassword"
})
class DbAndCsvBatchAppTest {

@Test
void testMainMethod() {
// Arrange
String[] args = {"--spring.batch.job.name=DB_TO_CSV", "--spring.profiles.active=local"};
System.setProperty("sun.java.command", String.join(" ", args));

// Act
DbAndCsvBatchApp.main(args);

// Assert
// Main method execution doesn't throw exceptions
}
}

0 comments on commit b83a4f6

Please # to comment.