Here has sample code:
package com.test.batch;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
class BatchApplicationTests {
@Autowired
private ApplicationContext ctx;
@Test
public void testCommandline() throws Exception {
CommandLineRunner runner = ctx.getBean(CommandLineRunner.class);
runner.run("-name", "Job2");
}
}
No comments:
Post a Comment