屋小巧安置,田少勤耕耘,妻贱合夫心,此乃真富裕。——富兰克林
今天进行streampark
参数化单元测试,用来测试多个数据库下的兼容情况
package org.apache.streampark;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.streampark.console.core.entity.Application;
import org.apache.streampark.console.core.mapper.ApplicationMapper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
/**
* MapperTest
*/
class MapperTest {
@ParameterizedTest
@ValueSource(strings = {"pgsql", "mysql", "h2"})
void test(String profile) {
System.setProperty("spring.profiles.active", profile);
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(StreamParkConsoleBootstrap.class).profiles(profile).run()) {
ApplicationMapper applicationMapper = context.getBean(ApplicationMapper.class);
Application app = new Application();
app.setProjectName("test");
Assertions.assertDoesNotThrow(() -> applicationMapper.page(new Page<>(), app));
}
}
}
代码放到了这里:
streampark-mapper-test: streampark mapper测试,用于兼容多数据库