我有一个带有scalatest的scala项目,该项目为Hive生成sql脚本。我想检查验证生成的脚本。有一个hiverunner com.klarna
,但我只能在Java中找到示例。您能帮我在Scala中重写测试Java示例还是推荐另一个库?
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.klarna</groupId>
<artifactId>hiverunner</artifactId>
<version>5.1.1</version>
</dependency>
测试示例
import com.klarna.hiverunner.HiveRunnerExtension;
import com.klarna.hiverunner.HiveShell;
import com.klarna.hiverunner.annotations.HiveSQL;
import com.klarna.hiverunner.data.TsvFileParser;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(HiveRunnerExtension.class)
public class Test2 {
@HiveSQL(files = {})
private HiveShell shell;
@BeforeEach
public void setupDatabase() {
shell.execute("CREATE DATABASE source_db");
.....
}
@Test
public void insertRowsFromCode() {
shell.insertInto("source_db", "test_table")
....
}