Hi there,
has already somebody a simple UnitTest-framework for a138?
@lexikos: Do you still use a own version of Uberi's YUnit (https://github.com/Uberi/Yunit) - and are willing to share it?
[a138+] UnitTest-Framework? Topic is solved
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: [a138+] UnitTest-Framework? Topic is solved
i think i finally got this figured out for v2beta1
please check it and test it out for any bugs:
https://github.com/Uberi/Yunit/tree/v2
Re: [a138+] UnitTest-Framework?
I kept this topic open on my phone and was reminded to reply several times over the last month, but of course, always while using my phone and not being in a position to type a proper reply.
I had only been updating the core part of Yunit (Yunit.ahk) and had not bothered with version control.
Yunit is described as "super simple", but for how I use it, it is over-engineered. I tried the GUI at first and quickly found that it wasn't useful to me; I prefer to have the tests print to the editor's output pane and immediately exit. Using the Yunit class directly was inconvenient, so I've been using shortcut functions since early on. My test scripts generally consist of:
Although I actually use a replacement for YunitStdOut which changes the format slightly.
After thinking about what Yunit actually does that I use, I worked out that the following was sufficient to replace it for my existing tests:
I had only been updating the core part of Yunit (Yunit.ahk) and had not bothered with version control.
Yunit is described as "super simple", but for how I use it, it is over-engineered. I tried the GUI at first and quickly found that it wasn't useful to me; I prefer to have the tests print to the editor's output pane and immediately exit. Using the Yunit class directly was inconvenient, so I've been using shortcut functions since early on. My test scripts generally consist of:
- tests followed by a list of classes.
- Tests defined as methods of classes. The methods are generally self-contained; I generally do not use __new/__delete, Begin/End, or ExpectedException.
- A series of related assertions with assert expression, throws ()=> expression (which passes only if the expression throws an exception) and equals expression, value.
Code: Select all
tests(t*) => Yunit.Use(YunitStdOut).Test(t*)
assert(p*) => Yunit.Assert(p*)
equals(a, b) => assert(a == b, (a is Number ? a : '"' a '"') ' != ' (b is Number ? b : '"' b '"'))
throws(f, p*) {
try f()
catch
return
assert(false, p*)
}
After thinking about what Yunit actually does that I use, I worked out that the following was sufficient to replace it for my existing tests:
Code: Select all
tests(classes*) {
for testclass in classes {
env := testclass()
for name in ObjOwnProps(testclass.Prototype) {
if SubStr(name, 1, 2) != '__' {
try
env.%name%()
catch as e
print "FAIL: " type(env) "." name errline(e)
else
print "PASS: " type(env) "." name
}
}
}
errline(e) => "`n" StrReplace(e.File, A_InitialWorkingDir "\") " (" e.Line ") : " e.Message
print(s) => FileAppend(s "`n", "*")
}
assert(condition, message:="FAIL", n:=-1) {
if !condition
throw Error(message, n)
}
equals(a, b) => assert(a == b, (a is Number ? a : '"' a '"') ' != ' (b is Number ? b : '"' b '"'), -2)
throws(f, m:="FAIL (didn't throw)") {
try f()
catch
return
assert(false, m, -2)
}
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: [a138+] UnitTest-Framework?
@guest3456 - thanks for the update of YUnit. Started using it ...
@lexikos - will have a look into it.
@lexikos - will have a look into it.
Who is online
Users browsing this forum: Hansielein, TAC109 and 59 guests