chore: migrate assertions in all unit tests in PrepareBoostTaskTest from jUnit to AssertJ. (#45718)

Summary:
https://github.com/facebook/react-native/issues/45596

Migrated all the assertions to use `assertThat()` function from AssertJ.
Also updated the `prepareBoostTask_withMissingConfiguration_fails` test to use `assertThatThrownBy` to check if the tested task throws a given exception.

## Changelog:
Migrate tests to assertj in these files:

- `packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareBoostTaskTest.kt`

[INTERNAL] [CHANGED] - Migrated PrepareBoostTaskTest from junit.Assert to assertj.core.api.Assertions.

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/45718

Test Plan:
All tests pass when `./gradlew -p packages/gradle-plugin test` command is ran.

<img width="454" alt="image" src="https://github.com/user-attachments/assets/9e954f7b-2208-48a9-ae15-ab642252e6da">

Reviewed By: GijsWeterings

Differential Revision: D60284566

Pulled By: cortinico

fbshipit-source-id: 11af0a0ca574f935e6aab3a7855b5daaeab1a718
This commit is contained in:
Jakub Urban
2024-07-26 05:45:26 -07:00
committed by Facebook GitHub Bot
parent f4435115cc
commit 9bddcdef85
@@ -10,7 +10,8 @@ package com.facebook.react.tasks.internal
import com.facebook.react.tests.createProject
import com.facebook.react.tests.createTestTask
import java.io.*
import org.junit.Assert.*
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatThrownBy
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
@@ -19,11 +20,13 @@ class PrepareBoostTaskTest {
@get:Rule val tempFolder = TemporaryFolder()
@Test(expected = IllegalStateException::class)
@Test
fun prepareBoostTask_withMissingConfiguration_fails() {
val task = createTestTask<PrepareBoostTask>()
task.taskAction()
assertThatThrownBy { task.taskAction() }
.isInstanceOf(IllegalStateException::class.java)
.hasMessage(
"Cannot query the value of task ':PrepareBoostTask' property 'boostVersion' because it has no value available.")
}
@Test
@@ -43,7 +46,7 @@ class PrepareBoostTaskTest {
}
task.taskAction()
assertTrue(output.listFiles()!!.any { it.name == "CMakeLists.txt" })
assertThat(output.listFiles()).extracting("name").contains("CMakeLists.txt")
}
@Test
@@ -62,7 +65,7 @@ class PrepareBoostTaskTest {
}
task.taskAction()
assertTrue(File(output, "asm/asm.S").exists())
assertThat(File(output, "asm/asm.S")).exists()
}
@Test
@@ -81,7 +84,7 @@ class PrepareBoostTaskTest {
}
task.taskAction()
assertTrue(File(output, "boost_1.0.0/boost/config.hpp").exists())
assertThat(File(output, "boost_1.0.0/boost/config.hpp")).exists()
}
@Test
@@ -100,6 +103,6 @@ class PrepareBoostTaskTest {
}
task.taskAction()
assertTrue(File(output, "boost_1.0.0/boost/config.hpp").exists())
assertThat(File(output, "boost_1.0.0/boost/config.hpp")).exists()
}
}