在 Wren 軌道上測試

了解如何在 Exercism 上測試你的 Wren 練習


用以下指令執行測試:

$ wrenc exercise-name.spec.wren

例如 hello-world:

$ wrenc hello-world.spec.wren

了解略過測試

skip方法會指示測試套件不要執行某個測試。

  • 為什麼要略過它們?

這是為了讓使用者能一次專注在一個測試上,並在逐步完成解法的過程中,一個一個把它們啟用。

  • 如何啟用它們?

一個被略過的測試:

// this test will be skipped and not run
skip.test("title cased phrases") {
    Expect.value(Acronyms.parse("Portable Network Graphics")).toEqual("PNG")
}

只要把 skip.test 改成 do.test 就行了。

// now the test will be run normally
do.test("title cased phrases") {
    Expect.value(Acronyms.parse("Portable Network Graphics")).toEqual("PNG")
}

建立你的第一個 Wren 模組

這個 track 的測試會把你的實作當成 Wren 模組匯入來載入它:import "./bob" for Bob。這裡沒有什麼特殊語法可以用來匯出你的實作。只要把你的類別命名為 Bob,對應 for Bob 的匯入敘述,一切就會正常運作喔。

class Bob {
  static hey(message) {
    // Your solution to the exercise goes here
  }
}

你可以在 Wren Modularity documentation 找到更多關於模組的資訊。為了讓你更容易上手,每個練習的目錄裡都有一個 skeleton Wren 檔案。