-
Notifications
You must be signed in to change notification settings - Fork 60
ceylon.test: run Callables as tests #158
ceylon.test: run Callables as tests #158
Conversation
This allows to run Anything()s as tests. If you pack them into a tuple, you can also name them. With this change, you can run a test function several times with different parameters, like this: "Runs [[testFile]] for each file in [[testFileDirectory]]." TestRunner runner = createTestRunner([ for (file in testFileDirectory.files()) [() => testFile(file), file.name] // or, if you don’t care about the name: // () => testFile(file) ]);
Hi Lucas I'm not sure if this approach is correct. Interface I think that developers will most often run tests from ide (eg. selecting module/package/... and use Run as > Ceylon Test) or command line via In the near future, I would like to add some support "data providers", something like junit parametrized tests or theory, but in more ceylonish way. Maybe this will solve your use case. |
That’s the problem – both don’t support my use case (writing a tool that processes files, test it using input + expected output file pairs). Currently, I can either write a method for each file pair (which I’m doing here), or I can write one method which loops over the the files (with the disadvantage that I can’t easily see which test failed, since it’s only one test).
Probably, yes. That would be nice. But is there any particular reason why you shouldn’t be able to run arbitrary |
The only reason is that when developer run |
I looked at your code and with "data providers" should be possible write something like this.
|
I was about to argue that this would be a totally unreasonable assumption that no one would ever make because it doesn’t make sense and bla bla – until I remembered that I did try this out, and I did kind of hope that it would work :D So I guess you’re right there. The data providers look nice, are they coming soon? |
It's "ceylonic", dammit ;-) |
Not in Czech, it isn't |
haha |
Say it to Tako, he introduced this word into my dictionary :-), see [1] and [2]. In Czech it would be "ceyloní" ;-). [2] https://groups.google.com/d/msg/ceylon-dev/BcDNMVpGa80/bFftKrw6DBIJ |
Hopefully into 1.1. I'm waiting to this issue ceylon/ceylon-spec#847. |
@lucaswerkmeister Can I close this pull request and open new issue in sdk for support "data providers"? |
Yeah, alright. I think I’ll keep the branch in my fork, but I’ll be happy with data providers.
Compromise: ceylonicish code. class Klazz() {
variable shared String name = "hi";
shared String getName() => name;
shared void setName(String newName) => name = newName;
} Kinda ceylonic, kinda not :-D |
This allows to run
Anything()
s as tests. If you pack them into a tuple, you can also name them.With this change, you can run a test function several times with different parameters, like this:
The code for the
CallableTestExecutor
is mostly copied from theMethodTestExecutor
, with a lot of stuff that’s not possible onCallable
s (callbacks from annotations etc.) removed.What do you think?