Commit b6eb7985 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

start of unit testing

parent f8141446
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,3 +6,4 @@
.idea
/config.xml
/dist
tests-output.xml
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -127,6 +127,12 @@ feed: ## Insertion de sources XML
    echo $(path)" ajouté à la base 'max'."
.PHONY: feed

tests: ## Exécution des tests unitaires
	$(shell cp config.xml.sample config.xml)
	-@.max/basex/bin/basex -c"TEST $(SRC_DIR)/test" > tests-output.xml # '-' prefix means ok to fail
	@.max/basex/bin/basex src/resources/tests-result.xq
.PHONY: tests

help: ## Affiche cette aide
	@echo "\nChoisissez une commande. Les choix sont:\n"
	@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[0;36m%-12s\033[m %s\n", $$1, $$2}'
+12 −0
Original line number Diff line number Diff line
xquery version "3.0";

let $output := "tests-output.xml"
let $nl := "
"
let $doc := doc("../../" || $output)

let $res :=
    for $ts in $doc//testsuite
     return "* " || $ts/@name || " : tests : " || $ts/@tests  || " / failures : " || $ts/@failures  || " / errors : " || $ts/@errors || $nl

return $nl || $res || $nl || '=> Tests done in ' || $doc/testsuites/@time || $ nl
        || $nl || "Full report available in " || $output || $nl

src/test/conf.xqm

0 → 100644
+26 −0
Original line number Diff line number Diff line
module namespace test = 'https://certic.unicaen.fr/max/tests';

import module namespace conf = 'https://certic.unicaen.fr/max/conf' at '../main/core/conf.xqm';


declare %unit:test function test:get-vocabulary-bundle(){
    unit:assert-equals(conf:get-vocabulary-bundle(), "max-dumb-tei-bundle")
 };

 declare %unit:test function test:get-languages() {
    let $languages-ok := ('fr','en')
    let $languages-nok := ('fr','es')
    return (
            unit:assert-equals(conf:get-languages(), $languages-ok),
            unit:assert(conf:get-languages()=$languages-nok, fn:false())
           )
};

declare %unit:test function test:get-title(){
	 unit:assert(conf:get-title() != "", fn:true)
};


declare %unit:test function test:is-dev-mode(){
	unit:assert(conf:is-dev-mode(), fn:true)
};