Sign in Join
Wiki copytemporary

Feature Ideas/UnitTests

= Feature idea - Eclipse-style unit tests. =

Main idea

The main idea is to have ability to write and run Unit tests from a subpackage of main project. This is to avoid creating a special project specifically for UnitTests. By this way, creation and running of UnitTests will be significantly simplified.

IMHO, Unit Tests are very important. I also consider, that currently UnitTests support in Lazarus is very uncomfortable. And I believe, that it's one of the most important factors, or even the most important which limits dissemination and distribution of Lazarus and FreePascal.

Introduction and references

I decided to write my feature idea after the following discussions on the forum:

1 2

I consider that You are familiar with concept of unit testing. You can read about Unit tests on Wikipedia: Unit testing on wikipedia

If you are not familiar, please read some more articles about software testing in general (for example, Software Testing on Wikipedia) and why unit tests are so important and why people need them (e.g., Purpose of unit testing).

Example: JUnit tests in Eclipse Maven Project

Let me show, how it is implemented in Eclipse Maven Project (using screenshots from Package Explorer in Eclipse).

Here is a sample project structure of Eclipse Maven Project. There are several packages in one project. Main program code is located in src/main/java. And Unit tests are located in the same project, but as a separated package - src/test/java. Physically, it's different folders on the filesystem.

So, it's very easy to create and run UnitTests for an IDE user. All the user need is:

Note: Maven features - not directly relevant to the main feature idea of this page.

There are also 2 resource folders - src/main/resources and src/test/resources. This is a cool feature of Maven. For example, if your class uses my_property_file.txt to load properties, you can have 2 files with this filename, but with different content in main/resources and test/resources. Thus, when you will run one of classes (in Java, one project can have several runnable classes, not just 1 program unit; class could be runnable as Application if it has method main()) in the src/main, it will use property file from (will look for my_property_file.txt in) src/main/resources. But, if you run a JUnit test of the same class from src/test, the same class will load properties from (will look for my_property_file.txt in) src/test/resources.

Conclusion


From the Free Pascal wiki, page "Feature Ideas/UnitTests", as it stood on 2012-06-06 after a change by Chronos, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Edited on wiki.freepascal.org by 2 people, 2012

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
MvampireFeature idea - Eclipse-style unit tests. The main idea is to have ability to run Unit tests from a subpackage of main project.
MvampireConclusion
MvampireFeature idea - Eclipse-style unit tests.
MvampireExample: JUnit tests in Eclipse Maven Project
Chronoscategory

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.