unit testing

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

unit testing

fschmidt
Administrator
In Java I had very little interest in unit testing, so I don't know much about it.  In an untyped language like Luan, there needs to be some testing functionality to make up for the lack of compile-time checking.  But my understanding is that unit testing doesn't do this.  My understanding is that a unit test tests one unit/module.  I still have no interest in this.  What I want is that if module X depends on module Y, then module X should contain some code, not to test itself, but rather to test that the functions that needs from module Y are available and work as expected.  Hugo, have you heard of anything like this?  I will look into it later.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

Hugo <Nabble>
fschmidt wrote
What I want is that if module X depends on module Y, then module X should contain some code, not to test itself, but rather to test that the functions that needs from module Y are available and work as expected.
I am not sure I understand this. Do you mean that each module should contain some test code to check if the needed modules are working as expected? In general, unit tests are kept separate from the main code, but I guess you could keep things together as local functions (so that no one can call them except the module itself). Is this what you have in mind?

Actually I am a little bit confused about this. For example, look at the String module. You could have unit tests specific for that module (no other dependencies need to be checked). If two modules depend on the String module, they don't have to test the String module again, right?
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

fschmidt
Administrator
The whole point is to test dependencies.  So if module X calls Y.fnA() and in Y fnA is renamed to fnB, then I want to catch this broken dependency.  In Java, the compiler would do this but not in Luan.

I started reading about unit testing and I realize that what I am talking about isn't unit testing at all, but it is related a little, so I will read more and figure it out.  I just want to make sure you understand the issue so that you can make a suggestion if you have any.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

Hugo <Nabble>
I think you could create some small programs and run them as tests. If all programs run without exceptions and generate the expected results, then you can assume everything is working as expected. Does this make sense?
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

fschmidt
Administrator
No it doesn't.  What you are describing here is unit testing.  My feeling/intuition is that writing good unit tests is hard and not worth the effort.  But testing dependencies is much easier.  I will read more about unit testing and then we can discuss this, so you can assign this back to me.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

Hugo <Nabble>
You can read more about this, as you said, but I don't think you can easily escape the test programs that I mentioned. And the test programs don't necessarily mean unit testing. It is just testing and making sure things work as expected. That seems to be the easiest (and probaly the most fun) option. I don't see what you can do beyond that. Back to you.
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

fschmidt
Administrator
In reply to this post by Hugo <Nabble>
What kind of small test programs?

Let me give you a specific example.  Suppose you have user.name and you use this in web pages.  Then in User you change user.name to user.first_name, user.last_name, and user.full_name() .  You will need to change each use of user.name to either user.first_name or user.full_name() .  With Java the compiler would catch all cases and you would fix them.  How should this work in Luan?
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

Hugo <Nabble>
The example you gave refers to an entire app, so this is more complex. You would have to create a bunch of luan programs that simulates a real user and test every single page and every possible path inside those pages (e.g., submit forms, etc.).

For smaller modules, this should be a bit easier. But, yes, the principle would be the same: create programs that explore the paths within that module. I don't see a way around this, unless you want to build a smart parser that would look at the code and at the modules and try to detect issues (just like a human analyzing the code), but that's even harder. I don't see much beyond these options.
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

fschmidt
Administrator
My original idea was to somehow express the dependencies in test code for each module/page.  But I changed my mind on this.  Now I think there should be one big test program that tests most paths on the pages.  In Java this would be very difficult because simulating the Servlet API is hard.  But I think this is much easier in Luan.  Does this make sense?  Before I implement anything for this, I would like to discuss it on Skype.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

Hugo <Nabble>
Okay. We can talk about this any time next week.
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

fschmidt
Administrator
If you are satisfied with how testing works, you can close this thread.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

Hugo <Nabble>
Okay, closing thread.
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

fschmidt
Administrator
In reply to this post by fschmidt
I need to add internal luan tests.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: unit testing

fschmidt
Administrator
done in rev 272.  closing
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture