Recent

Author Topic: Wish list: Eclipse-style unit tests; clear project structure.  (Read 18410 times)

mvampire

  • Jr. Member
  • **
  • Posts: 62
Wish list: Eclipse-style unit tests; clear project structure.
« 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)?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #1 on: January 09, 2012, 03:04:14 am »
We have a dedicated page 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.
« Last Edit: January 09, 2012, 03:12:43 am by Leledumbo »

CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #2 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

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #3 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.

mvampire

  • Jr. Member
  • **
  • Posts: 62
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #4 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.
« Last Edit: January 09, 2012, 02:57:38 pm by mvampire »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #5 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. 
« Last Edit: January 09, 2012, 03:13:51 pm by marcov »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #6 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 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.

mvampire

  • Jr. Member
  • **
  • Posts: 62
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #7 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.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4458
  • I like bugs.
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #8 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
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #9 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
and the second part is valid to current thread.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #10 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.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #11 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.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #12 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
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4458
  • I like bugs.
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #13 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
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Wish list: Eclipse-style unit tests; clear project structure.
« Reply #14 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 ;)

Regards,
Sven

 

TinyPortal © 2005-2018