Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example in test guideline #22343

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions docs/src/main/sphinx/develop/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,18 @@ create per-method, and a allow parallel execution of tests with `CONCURRENT`:
```java
@TestInstance(PER_CLASS)
@Execution(CONCURRENT)
public class TestJoin
final class TestJoin
{
private final QueryAssertions assertions = new QueryAssertions();

@AfterAll
public void teardown()
void teardown()
{
assertions.close();
}

@Test
public void testXXX()
void testXXX()
{
assertThat(assertions.query("""
...
Expand All @@ -248,25 +248,25 @@ Avoid managing the lifecycle of a Closeable like a connection with

```java
@TestInstance(PER_METHOD)
class Test
final class Test
{
private Connection connection;

@BeforeEach
public void setup()
void setup()
{
// WRONG: create this in the test method using try-with-resources
connection = newConnection();
}

@AfterEach
public void teardown()
void teardown()
{
connection.close();
}

@Test
public void test()
void test()
{
...
}
Expand All @@ -277,19 +277,19 @@ Using a try with resources approach allows clean parallelization of tests and
includes automatic memory management:

```java
class Test
final class Test
{

@Test
public void testSomething()
void testSomething()
{
try (Connection connection = newConnection();) {
...
}
}

@Test
public void testSomethingElse()
void testSomethingElse()
{
try (Connection connection = newConnection();) {
...
Expand All @@ -304,7 +304,7 @@ Avoid using fake abstraction for tests.

```java
@DataProvider(name = "data")
public void test(boolean flag)
void test(boolean flag)
{
// WRONG: use separate test methods
assertEqual(
Expand All @@ -316,7 +316,7 @@ public void test(boolean flag)
Replace with simplified separate assertions:

```java
public void test()
void test()
{
assertThat(...).isEqualTo(...); // case corresponding to flag == true
assertThat(...).isEqualTo(...); // case corresponding to flag == false
Expand All @@ -329,7 +329,7 @@ Do not develop a custom parallel test execution framework:

```java
@Test(dataProvider = "parallelTests")
public void testParallel(Runnable runnable)
void testParallel(Runnable runnable)
{
try {
parallelTestsSemaphore.acquire();
Expand All @@ -347,7 +347,7 @@ public void testParallel(Runnable runnable)
}

@DataProvider(name = "parallelTests", parallel = true)
public Object[][] parallelTests()
Object[][] parallelTests()
{
return new Object[][] {
parallelTest("testCreateTable", this::testCreateTable),
Expand All @@ -373,7 +373,7 @@ Do not create a custom parameterized test framework:

```java
@Test
public void testTinyint()
void testTinyint()
{
SqlDataTypeTest.create()
.addRoundTrip(...)
Expand Down