Lazarus

Miscellaneous => Suggestions => Topic started by: mvampire on January 09, 2012, 01:17:17 am

Title: Wish list: Eclipse-style unit tests; clear project structure.
Post by: mvampire on January 09, 2012, 01:17:17 am
Can I write a wish here? ;)

As I wrote at http://lazarus.freepascal.org/index.php/topic,15681.0.html,

I'm dreaming about:

1) Eclipse-style unit tests in Lazarus, when tests are in the same project, and I can right click on the unit/test (or package with multiple tests) and run it as a test.

2) Caused by 1, more sophisticated Project Inspector / Package Explorer and clear project structure. What I wish - is to have some kind of packages, like different folders for source, tests, resources, etc. And also ability to control (move/delete/rename) packages/folders/files. I assume it would be cool if project structure will be created automatically when starting new project. To be precise, Maven-like project structure, when tests and main source have different resources (so it becomes possible to use different files with properties for tests and main program) will be awesome!

3) Also caused by 1st - possibility to have several runnable units (classes) in 1 project - also like in Eclipse. Or it's already possible?

Can I ask if there are any plans for this? If not, is it possible to plan it? ;) Generally, if somebody wants some feature, which steps he can do to put his wish into the project roadmap? Which criterias it should pass to be accepted?

Thanks.

P.S. If I, in some (not near) future will have time for it, can I start/try to implement it by myself? How to start then (but please don't describe it too precisely, because even if I will have sufficient skills for it, I probably have no time for it now)?
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: Leledumbo on January 09, 2012, 03:04:14 am
We have a dedicated page (http://wiki.lazarus.freepascal.org/Feature_Ideas) for wish list ;)

1) It probably could be implemented by automatically generating test project in temporary directory that uses the test case unit and running it.

2) It's already possible via project templates package possibly combined with build modes.

3) I don't understand this one... units aren't meant to be run, programs are.
Quote
Can I ask if there are any plans for this?
Not sure, but I guess no plan yet.
Quote
If not, is it possible to plan it?
If you could convince the developers, why not?
Quote
Generally, if somebody wants some feature, which steps he can do to put his wish into the project roadmap? Which criterias it should pass to be accepted?
From my point of view: proven to be useful, not breaking compatibility, there's (an) implementor(s) and maintainer(s).
Quote
If I, in some (not near) future will have time for it, can I start/try to implement it by myself?
Sure.
Quote
How to start then (but please don't describe it too precisely, because even if I will have sufficient skills for it, I probably have no time for it now)?
Start messing up with your installation ;)
I mean, understand the source code and modify as necessary to make the features implemented. Then try submitting the patches and explain to developers.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: CaptBill on January 09, 2012, 07:56:24 am
This is a task for Tinycore Linux. You have an excellent foundation with a repository system, your own personal one. You simply are building extensions/packages like a .deb (Debian).
Now you have a system based on mounting/dismounting your custom "extensions", packages, or whatever ...like virtual hard disks even.
With a standardized system like this setup, you can even mount files from a remote server. Or I can connect to your "repo" and open a package from your personal FTP repo, etc.
Tinycore is so small (7 megs) booting from CD/DVD is the way to go.say bybye to you virus scanner. You get a pristine boot envy time. So th OS loads to ram then the FTP/http Extension server starts and you next mount a file system from your custom repo.

The TProcess component is your go to component. All the tools can be driven strait from the command line.

Definitly a good one for the wish list

Cheers
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: marcov on January 09, 2012, 02:41:58 pm
which steps he can do to put his wish into the project roadmap? Which criterias it should pass to be accepted?

The best way is to submit a patch. If the feature is very involved, it is better to have some minimal test implementation first (that you are willing to throw away)

There is no project roadmap (except for improving current widgets), just the todo of each developer of what he wants to implement.

Quote
P.S. If I, in some (not near) future will have time for it, can I start/try to implement it by myself? How to start then (but please don't describe it too precisely, because even if I will have sufficient skills for it, I probably have no time for it now)?

Always, best is to first do a hackish solution to get to a prove of concept situation, and then ask regular developers about it. (they can tell you if it needs to be spun into a package, can be a standard feature etc).

Note that there is not only the matter of implementation but also of longterm maintainership.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: mvampire on January 09, 2012, 02:48:37 pm
Thank You for the good and fast answers!


1) It probably could be implemented by automatically generating test project in temporary directory that uses the test case unit and running it.

...

3) I don't understand this one... units aren't meant to be run, programs are.


Yes, maybe I wrote a bit unclear.

I suggest an ability to have unit-tests in the same project with tested units. Unit test is not a program, it's a unit. So I mean running such a unit with unit test, without running the whole program.
Generally, but not necessary, I want an ability to have several programs in the project, not only running unit tests possibility.
For example, let's assume that there are following units in the project:

CarSelling.pas - program to sell cars, which uses SaveDataToDatabase.pas unit to save some data to database
BycicleSelling.pas - program to sell bicycles, which also uses SaveDataToDatabase.pas unit to save some data to database
SaveDataToDatabase.pas - unit providing database functionality
TestAutoSelling.pas - unit with test case for testing CarSelling.pas program
TestBicycleSelling.pas - unit with test case for testing BicycleSelling.pas program
TestDatabaseSave - unit with test case for testing SaveDataToDatabase.pas unit

So, can I compile and run CarSelling, BicycleSelling (as separate programs) and all 3 unit tests (to be run as unit tests, not as programs) from 1 project? As I undestood - currently it's not possible.

Currently, for unit tests a separate project should be created, as I have understood, which is uncomfortable, IMHO. On the other hand, I don't see any IDE/compiler limitations to implement/automate this and make unit tests available without creation of an extra, separate project for unit tests only. Moreover, as I mentioned in the other thread, I think that tests are very important and providing a comfortable clear and well-structured enviroment for unit tests can significantly increase competitiveness and attractiveness of Lazarus.

Quote

2) It's already possible via project templates package possibly combined with build modes.


Can I ask then how exactly can I get Maven-like project structure for my project? With different property files for tests and main program?
I also meant there that it would be cool if all new projects will already have some basic structure by default (when starting a new project), and not all-files-in-one-folder.

Quote
We have a dedicated page for wish list

Thanks, I will then describe all my ideas more precisely within next days there, also using Eclypse screenshots.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: marcov on January 09, 2012, 03:07:38 pm


I suggest an ability to have unit-tests in the same project with tested units. Unit test is not a program, it's a unit. So I mean running such a unit with unit test, without running the whole program.
Generally, but not necessary, I want an ability to have several programs in the project, not only running unit tests possibility.
For example, let's assume that there are following units in the project:

That sounds like project groups, like Delphi has it. 
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: Leledumbo on January 09, 2012, 04:50:25 pm
Quote
Unit test is not a program, it's a unit. So I mean running such a unit with unit test, without running the whole program.
As I said earlier, this is impossible. Units cannot be run, only programs do (though, as I said earlier again, the program code could be temporarily generated upon request to run this unit test).
Quote
Can I ask then how exactly can I get Maven-like project structure for my project? With different property files for tests and main program?
I also meant there that it would be cool if all new projects will already have some basic structure by default (when starting a new project), and not all-files-in-one-folder.
I don't know what Maven project structure looks like, but this wiki page (http://wiki.lazarus.freepascal.org/Project_Templates) would explain how to create a custom project structure. Basically, you create a project with the structure you want, and save it as template. Next time you create a project, choose from this template.
Quote
That sounds like project groups, like Delphi has it.
Or solution, stealing M$ term.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: mvampire on January 09, 2012, 05:52:08 pm
Quote
Unit test is not a program, it's a unit. So I mean running such a unit with unit test, without running the whole program.
As I said earlier, this is impossible. Units cannot be run, only programs do (though, as I said earlier again, the program code could be temporarily generated upon request to run this unit test).

OK. I was just talking from user perspective. Does not matter how exactly it wll be implemented, I meant that I would like to right click on one of the unit in the project (e.g, in project inspector) and click 'run as unit test case'. Then, of course, some code could be temporarily generated, but, as a user (!) I don't want to think about such code (program code to run unit test case). I (AS A USER, not personally) want to: have a project - make a package with unit tests inside this project - create an unit test there - click on unit test - click 'run as unit test' - see the results - see on which line in unit being tested I have a problem.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: JuhaManninen on January 09, 2012, 07:53:57 pm
This is a task for Tinycore Linux. You have an excellent foundation with a repository system, your own personal one. You simply are building extensions/packages like a .deb (Debian).
[...]

CaptBill, did you write the message? It looks like a spam sent by a bot, not relating to the issue.

Juha
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: Blaazen on January 09, 2012, 09:07:50 pm
@Juha, CaptainBill

This seems to be "mixed" answer.
The first part probably belongs to this thread: http://www.lazarus.freepascal.org/index.php/topic,15740.msg84943/topicseen.html#new (http://www.lazarus.freepascal.org/index.php/topic,15740.msg84943/topicseen.html#new)
and the second part is valid to current thread.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: CaptBill on January 10, 2012, 02:44:43 am
This is a task for Tinycore Linux. You have an excellent foundation with a repository system, your own personal one. You simply are building extensions/packages like a .deb (Debian).
[...]

CaptBill, did you write the message? It looks like a spam sent by a bot, not relating to the issue.

Juha

Hi Juha,
I know I sound like a Tinycore salesman lately, haha. What mvampire desires is achievable, i believe, with a local repository system. You can have a "project package" (package=collection of extensions). Just need to follow the file mounting paradigm in place already in Tinycore. It takes the repo concept to another level, totally separating OS and file system. You don't "install apps" but instead you mount the extensions needed.

With this we have a system that can do the things we need with Lazarus like

Open into a minimalist mode with a FpGui specific environment for example.

Easily switch between multiple snapshots/versions of Fpc and Laz with no problem

Even switch out your window manager without a reboot for testing in different WMs.

The repo concept can be used for more than just downloading apps. Would be a good foundation to build what we are discussing. And Tinycore is structured well for this.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: Leledumbo on January 10, 2012, 02:59:33 am
Quote
OK. I was just talking from user perspective. Does not matter how exactly it wll be implemented, I meant that I would like to right click on one of the unit in the project (e.g, in project inspector) and click 'run as unit test case'. Then, of course, some code could be temporarily generated, but, as a user (!) I don't want to think about such code (program code to run unit test case). I (AS A USER, not personally) want to: have a project - make a package with unit tests inside this project - create an unit test there - click on unit test - click 'run as unit test' - see the results - see on which line in unit being tested I have a problem.
OK, I get it. Now please ask a feature request in the bugtracker and explain this to the developers. Good luck.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: BigChimp on January 10, 2012, 09:34:45 am
Hi Juha,
I know I sound like a Tinycore salesman lately, haha. What mvampire desires is achievable, i believe, with a local repository system. You can have a "project package" (package=collection of extensions). Just need to follow the file mounting paradigm in place already in Tinycore. It takes the repo concept to another level, totally separating OS and file system. You don't "install apps" but instead you mount the extensions needed.

With this we have a system that can do the things we need with Lazarus like

Open into a minimalist mode with a FpGui specific environment for example.

Easily switch between multiple snapshots/versions of Fpc and Laz with no problem

Even switch out your window manager without a reboot for testing in different WMs.

The repo concept can be used for more than just downloading apps. Would be a good foundation to build what we are discussing. And Tinycore is structured well for this.
CaptBill,

I still don't see how this applies to unitTESTING a project that one is writing. We're not talking about testing Lazarus packages etc... Perhaps I misunderstand what you're saying; if so, try again please  :)

If I understand correctly, mvampire wanted (among other things) tighter integration of a test harness for (unit) tests when coding a project. These unit tests obviously need to refer to the main code in order to test them.

He would like to be able to run unit tests on the code in that project while in the Lazarus IDE, without having to close the primary project and opening a unit test project, or having two Lazarus instances with primary+unit test projects.
Currently this is not possible as Lazarus will only allow setting up a different project containing the FPC/Lazarus unit testing framework; Lazarus allows only one item/unit within a project to be run/debugged.

For this to work, there would be a need to add multiple "projects" (=regular program+associated unit tests) inside a "project group" ("solution" in Microsoft Visual Studio) and let the user choose with the IDE which one he wants to run. This would be either the normal code or the unit tests for the code.

Thanks,
BigChimp
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: JuhaManninen on January 10, 2012, 09:47:31 am
@CaptBill:
> I know I sound like a Tinycore salesman lately, haha. What mvampire desires is achievable, i believe, with a local repository system
> [...]

Ok, then it makes some sense. However, unit testing should be easy on every platform / OS. It may be better to implement it in Lazarus.

@mvampire:
You can make a feature request in bugtracker, true, but I guess nobody will implement it soon.
There are ~1200 open issues for Lazarus, some of them feature requests. The developers have their own priority lists and there are too few developers anyway.
Best would be if you could implement it by yourself (as you mentioned). Nobody can describe it precisely but you just have to study the code and experiment with it. There can be a feature branch in SVN server for your code if needed, or you can make your own branch in a public repo (GitHub, SourceForge etc.).
When you have an idea of the existing code you can ask questions in mailing list. Developers are helpful if you show a true effort to learn and implement something.
That's what I did less than 3 years ago myself. I fixed some bugs and then made a big change to the Configure Build Lazarus dialog.

Be warned though: your feature will take some time because the project and package related code in Lazarus is quite complex.

Juha
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: PascalDragon on January 10, 2012, 11:29:15 am


I suggest an ability to have unit-tests in the same project with tested units. Unit test is not a program, it's a unit. So I mean running such a unit with unit test, without running the whole program.
Generally, but not necessary, I want an ability to have several programs in the project, not only running unit tests possibility.
For example, let's assume that there are following units in the project:

That sounds like project groups, like Delphi has it.

And those I already requested here (http://bugs.freepascal.org/view.php?id=18518) ;)

Regards,
Sven
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: mvampire on January 15, 2012, 06:59:23 pm
I have written a feature request in the wiki:

http://wiki.lazarus.freepascal.org/Feature_Ideas/UnitTests
http://wiki.lazarus.freepascal.org/Feature_Ideas#Write_and_run_unit_tests_from_subpackage_of_project_being_tested

And also submitted it as a feature on bug tracker:

http://bugs.freepascal.org/view.php?id=21094
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: CaptBill on January 21, 2012, 10:11:13 am
It would take some ingenuity on your part to figure out the details for what you want. I just feel that Tinycore would be a great platform to start from for these types of scenarios/setups.

Possibly a virtual machine would be a simple strategy. Tinycore boots so fast and can be scripted (no VitualBox), would be the ideal scenario.

I think it could be a good foundation to achieve your goal and an ideal approach, was my idea.

Juha,
I see your point about being OS independent.

Sorry for delay in answering.

Cheers
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: mvampire on January 24, 2012, 10:21:17 am
... Tinycore ...

Please do not write this spam here anymore. I don't see any relevance of Linux distro you propose with my question about integration of unit tests in Lazarus IDE.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: CaptBill on January 24, 2012, 12:13:29 pm
Ok then.

How about you just learn standard testing practices instead then, when your not so busy.(unit testing, sheesh!)

Almost sounds like you are trying to find faults with Lazarus, and asking questions that are silly and expect it to program itself, like Eclipse apparently does.

And filed a bug?





Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: mvampire on January 24, 2012, 02:00:31 pm
Thanks.

How about you just learn standard testing practices instead then, when your not so busy.(unit testing, sheesh!)

Hm, I undestand that I know just basics, but I don't need more for my job and study now. I just have other tasks with higher priority.

Quote
Almost sounds like you are trying to find faults with Lazarus, and asking questions that are silly and expect it to program itself, like Eclipse apparently does.

I'm a student and my topic is BGP (routing protocol). I have written a program (for myself, to calculate some statistics I was interested in) to analyse huge number of BGP messages. I made it in Lazarus, because Pascal was the only language I knew good. And all questions I asked - were real questions, which I couldn't solve by myself or find any other solution.

Also I'm currenty working as Java Developer (I have only about 1 year experience), I use Eclipse.

Now my Pascal program become quite big (4000 lines) and I needed to test it, because I wanted to publish results. And I need to trust the results. That's why I needed testing, also unit tests for several modules. When I started with Unit tests in Lazarus I noticed that it could be much more comfortable, so I decided to write a suggestion, that's it.

Quote
And filed a bug?

Not bug, but feature request (which was suggested by Leledumbo) on the bugtracker.
Title: Re: Wish list: Eclipse-style unit tests; clear project structure.
Post by: felipemdc on January 24, 2012, 03:12:46 pm
Can I ask if there are any plans for this? If not, is it possible to plan it? ;) Generally, if somebody wants some feature, which steps he can do to put his wish into the project roadmap? Which criterias it should pass to be accepted?

I think that your best chance is to simply write the feature yourself and send the code.

Quote
P.S. If I, in some (not near) future will have time for it, can I start/try to implement it by myself? How to start then (but please don't describe it too precisely, because even if I will have sufficient skills for it, I probably have no time for it now)?

Yes, sure. I think it should be implemented as a package which acts as an IDE add on. I never wrote one myself, so I dont know where this is documented how to do that.

Here is one such bug report where someone sent us a new Lazarus package which is an IDE add-on: http://bugs.freepascal.org/view.php?id=21138

You could use this code as a starting point to check how IDE add-ons work if noone else has better suggestions.
TinyPortal © 2005-2018