p238049y / junit-try

springbootでjunitの環境を構築しテストコードについて勉強する
0 stars 0 forks source link

[タスク] Junitの導入 #1

Closed p238049y closed 4 months ago

p238049y commented 4 months ago
p238049y commented 4 months ago
image

演算子 ^ は使えないよ

p238049y commented 4 months ago

booleanにしないとね

p238049y commented 4 months ago
public class PostUserDataRequestTest {

    @Nested
    @DisplayName("ハッピーテスト")
    class HappyTest {

        @Test
        void _1と1をを足すと2になること () {
            var actual = 1+1;
            var expect = 2;

            Assertions.assertEquals(actual, expect);
        }
    }
}
Starting Gradle Daemon...
Gradle Daemon started in 1 s 435 ms

> Task :compileJava
> Task :processResources UP-TO-DATE
> Task :classes
> Task :compileTestJava
> Task :processTestResources NO-SOURCE
> Task :testClasses
> Task :test
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 13s
4 actionable tasks: 3 executed, 1 up-to-date
17:02:16: タスク  ':test --tests "com.p238049y.junit_app.presentation.controller.post.PostUserDataRequestTest$HappyTest._1と1をを足すと2になること"' の実行を完了しました。

テストに成功した

p238049y commented 4 months ago

GitHub Actionsについて何もわからないやつがなんちゃってCIを設定するまで(Spring Boot) ついでにCIジョブも設定しておくか

p238049y commented 4 months ago

https://github.com/p238049y/junit-try/pull/4

p238049y commented 4 months ago

https://zenn.dev/toliner/articles/1c6805bbf686e46be5f3

これだ

p238049y commented 4 months ago

https://kajiblo.com/springboot3-githubactions/

p238049y commented 4 months ago

環境構築時のメモは以下に記載する

https://qiita.com/lz910201/items/ee5546a614ed3ccaaa23 を参考に

Dependency requires at least JVM runtime version 17. This build uses a Java 16 JVM.

https://qiita.com/takahirom/items/5e8d7b69e873edb3dcaf

を参考にしたらビルドできた

    Starting Gradle Daemon...
    Gradle Daemon started in 1 s 744 ms
    > Task :prepareKotlinBuildScriptModel UP-TO-DATE

    Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

    You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

    For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

    BUILD SUCCESSFUL in 1m 4s
Execution failed for task ':bootRun'.
> Process 'command '/Library/Java/JavaVirtualMachines/amazon-corretto-21.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 17s
4 actionable tasks: 4 executed
024-07-06T01:17:27.910+09:00 ERROR 85590 --- [junit-app] [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

> Task :bootRun FAILED

Execution failed for task ':bootRun'.
> Process 'command '/Library/Java/JavaVirtualMachines/amazon-corretto-21.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 17s
4 actionable tasks: 4 executed