2017-02-25 48 views
1

我正在使用Eliom構建一個新項目,並且無法使用OUnit爲單元測試設置編譯過程。Eliom Framework中的單元測試

我有兩個文件:

Js_Client_Code.eliom - contains all of the client side code 
Project.eliom - contains all of the server side code (including opening Js_Client_Code.eliom) 

我以這種方式建立的文件,這樣我就可以不使用ocsigenserver上Js_Client_Code.eliom運行單元測試。

這是我的測試電流生成文件:

test: prep unit_tests  

prep: 
    eliomc -infer Js_Client_Code.eliom 
    js_of_eliom -linkall -a Js_Client_Code.eliom -o file_a.cma 
    eliomc -a -linkall Js_Client_Code.eliom -o file_b.cma 

# Code is here to move the cma files back to the parent directory, since they are written to _client/ and _server/ by default 

unit_tests: 
    ocamlfind ocamlc -thread -syntax camlp4o -package ounit,js_of_ocaml.syntax \ 
    -linkpkg -g -o UnitTests file_a.cma file_b.cma unit_tests.ml 

運行make test在外殼產生

File "unit_tests.ml", line 1: 
Error: Error while linking file_a.cma(Js_Client_Code): 
Reference to undefined global `Eliom_client' 

我誤解了Eliom/Js_of_ocaml編譯過程,或只是要對這個錯誤的辦法?

回答

0

根本沒有鏈接eliom庫,所以當然它缺少所有的外部模塊。

老實說,我不認爲你會設法以這種方式單元測試依賴於eliom的模塊。單獨測試非eliom部分並進行端到端的基於瀏覽器的測試(有很多的框架)可能會更容易。

如果你真的想嘗試,有關eliom(或ocsigenserver)手冊的解釋靜態鏈接。