JetBrains/educational-plugin

Create test for task

alfianyusufabdullah opened this issue · 2 comments

I have task like this:

fun main() {
    print("Hello Kotlin")
}

i'am already read this article. But it's just create a new funtion for the task. i just need to test value in print function. how i do that? like exercise for AtomicKotlin course in Hello, World! section.

Hi!
What you've found in AtomicKotlin course is a special type of task, and we don't have an interface to create this type of tasks yet. We are working on it, and hope soon it will be possible.

But now there is a tricky way to create them. It means that you will modify internal course structure xml-file. As modifying core course files is a delicate process, it's good practice to create copy of your project first.

So the process is the following:

  1. Create a copy of your existing project.
  2. Open in file manager a directory of a project you want to modify. Make sure, the project isn't opened in IDE.
  3. Go to <Project Directory>/.idea/study_project.xml.
  4. Find task you want to check an output of.
  5. Replace EduTask with OutputTask and save. Basically it should look like this.
  • Before:
<EduTask>
    <option name="customPresentableName" />
    <option name="descriptionFormat" value="HTML" />
    <option name="descriptionText" value="test" />
</EduTask>
  • After:
<OutputTask>
    <option name="customPresentableName" />
    <option name="descriptionFormat" value="HTML" />
    <option name="descriptionText" value="test" />
</OutputTask>
  1. Open your project. Add test/output.txt file containing desired output for your task.
  2. You're done!

If you have any questions, please write here.

Valentina

Saved my day! Thanks @evgraph