{"action":"created","issue":{"url":"https://api.github.com/repos/kotlintest/kotlintest/issues/174","repository_url":"https://api.github.com/repos/kotlintest/kotlintest","labels_url":"https://api.github.com/repos/kotlintest/kotlintest/issues/174/labels{/name}","comments_url":"https://api.github.com/repos/kotlintest/kotlintest/issues/174/comments","events_url":"https://api.github.com/repos/kotlintest/kotlintest/issues/174/events","html_url":"https://github.com/kotlintest/kotlintest/issues/174","id":224988507,"number":174,"title":"lateinit variable doesn't work with interceptTestCase","user":{"login":"lenguyenthanh","id":437967,"avatar_url":"https://avatars0.githubusercontent.com/u/437967?v=3","gravatar_id":"","url":"https://api.github.com/users/lenguyenthanh","html_url":"https://github.com/lenguyenthanh","followers_url":"https://api.github.com/users/lenguyenthanh/followers","following_url":"https://api.github.com/users/lenguyenthanh/following{/other_user}","gists_url":"https://api.github.com/users/lenguyenthanh/gists{/gist_id}","starred_url":"https://api.github.com/users/lenguyenthanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lenguyenthanh/subscriptions","organizations_url":"https://api.github.com/users/lenguyenthanh/orgs","repos_url":"https://api.github.com/users/lenguyenthanh/repos","events_url":"https://api.github.com/users/lenguyenthanh/events{/privacy}","received_events_url":"https://api.github.com/users/lenguyenthanh/received_events","type":"User","site_admin":false},"labels":[{"id":293015596,"url":"https://api.github.com/repos/kotlintest/kotlintest/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/kotlintest/kotlintest/milestones/8","html_url":"https://github.com/kotlintest/kotlintest/milestone/8","labels_url":"https://api.github.com/repos/kotlintest/kotlintest/milestones/8/labels","id":2487549,"number":8,"title":"2.0.2","description":null,"creator":{"login":"helmbold","id":5079980,"avatar_url":"https://avatars2.githubusercontent.com/u/5079980?v=3","gravatar_id":"","url":"https://api.github.com/users/helmbold","html_url":"https://github.com/helmbold","followers_url":"https://api.github.com/users/helmbold/followers","following_url":"https://api.github.com/users/helmbold/following{/other_user}","gists_url":"https://api.github.com/users/helmbold/gists{/gist_id}","starred_url":"https://api.github.com/users/helmbold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helmbold/subscriptions","organizations_url":"https://api.github.com/users/helmbold/orgs","repos_url":"https://api.github.com/users/helmbold/repos","events_url":"https://api.github.com/users/helmbold/events{/privacy}","received_events_url":"https://api.github.com/users/helmbold/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":1,"state":"open","created_at":"2017-04-28T07:02:30Z","updated_at":"2017-05-03T09:38:04Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2017-04-28T06:08:36Z","updated_at":"2017-05-09T04:29:54Z","closed_at":null,"body":"I have a problem with init `lateinit var` property in `interceptTestCase` method.\r\nHere is my example:\r\n```\r\nclass ExampleTest : StringSpec() {\r\n    private lateinit var someString: String\r\n\r\n    override fun interceptTestCase(context: TestCaseContext, test: () -> Unit) {\r\n        println(\"Start Testcase\")\r\n        someString = \"Hello\"\r\n        test()\r\n        println(\"End Testcase\")\r\n    }\r\n\r\n    init {\r\n        \"Hello should equal to Hello\" {\r\n            someString shouldEqual \"Hello\"\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nAnd here is out put:\r\n```\r\nStart Testcase\r\n\r\nkotlin.UninitializedPropertyAccessException: lateinit property someString has not been initialized\r\n\r\n\tat com.locata.myapplication.ExampleTest.access$getSomeString$p(ExampleTest.kt:7)\r\n\tat com.locata.myapplication.ExampleTest$1.invoke(ExampleTest.kt:18)\r\n\tat com.locata.myapplication.ExampleTest$1.invoke(ExampleTest.kt:7)\r\n\tat io.kotlintest.Spec$runTest$callable$1$1.invoke(Spec.kt:124)\r\n\tat io.kotlintest.Spec$runTest$callable$1$1.invoke(Spec.kt:15)\r\n\tat io.kotlintest.Spec$runTest$initialInterceptor$1$1.invoke(Spec.kt:116)\r\n\tat io.kotlintest.Spec$runTest$initialInterceptor$1$1.invoke(Spec.kt:15)\r\n\tat com.locata.myapplication.ExampleTest.interceptTestCase(ExampleTest.kt:12)\r\n\tat io.kotlintest.Spec$runTest$initialInterceptor$1.invoke(Spec.kt:116)\r\n\tat io.kotlintest.Spec$runTest$initialInterceptor$1.invoke(Spec.kt:15)\r\n\tat io.kotlintest.Spec$runTest$callable$1.call(Spec.kt:124)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n\r\n\r\nProcess finished with exit code 255\r\n```\r\n\r\nIt's happen for both 2.0.0 and 2.0.1."},"comment":{"url":"https://api.github.com/repos/kotlintest/kotlintest/issues/comments/300058419","html_url":"https://github.com/kotlintest/kotlintest/issues/174#issuecomment-300058419","issue_url":"https://api.github.com/repos/kotlintest/kotlintest/issues/174","id":300058419,"user":{"login":"lenguyenthanh","id":437967,"avatar_url":"https://avatars0.githubusercontent.com/u/437967?v=3","gravatar_id":"","url":"https://api.github.com/users/lenguyenthanh","html_url":"https://github.com/lenguyenthanh","followers_url":"https://api.github.com/users/lenguyenthanh/followers","following_url":"https://api.github.com/users/lenguyenthanh/following{/other_user}","gists_url":"https://api.github.com/users/lenguyenthanh/gists{/gist_id}","starred_url":"https://api.github.com/users/lenguyenthanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lenguyenthanh/subscriptions","organizations_url":"https://api.github.com/users/lenguyenthanh/orgs","repos_url":"https://api.github.com/users/lenguyenthanh/repos","events_url":"https://api.github.com/users/lenguyenthanh/events{/privacy}","received_events_url":"https://api.github.com/users/lenguyenthanh/received_events","type":"User","site_admin":false},"created_at":"2017-05-09T04:29:54Z","updated_at":"2017-05-09T04:29:54Z","body":"Just investigated this issue. In example above, We use oneInstancePerTest so the `someString` in test is in different instance with `someString` we initialized in `interceptTestCase`\r\n\r\nSo if we use \r\n```\r\n    override val oneInstancePerTest: Boolean\r\n        get() = false```\r\n\r\nor \r\n```\r\n    override fun interceptTestCase(context: TestCaseContext, test: () -> Unit) {\r\n        (context.spec as LateInitValuesTest).lateInitString = \"Hello\"\r\n        test()\r\n    }```\r\n\r\nOur test will work as expected.\r\n"}}
{"actor":{"display_login":"lenguyenthanh"}}