Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

60%
+1 −0
Q&A What is the purpose of grouping the tests in a `tests` module and is it possible to split them?

When you think about how to organize your test code, you should develop an understanding of your goals. Typical goals about test code organization (which typically includes helper code only needed...

posted 1y ago by Dirk Herrmann‭  ·  edited 1y ago by Dirk Herrmann‭

Answer
#4: Post edited by user avatar Dirk Herrmann‭ · 2023-06-10T07:47:55Z (over 1 year ago)
  • When you think about how to organize your test code, you should develop an understanding of your goals. Typical goals about test code organization (which typically includes helper code only needed for the tests) are:
  • * Ensure that test code does not become part of production code - for some kinds of software this can even be a strict requirement (for example in safety critical software) - even if the test code within the production code would be dead code or unreachable.
  • * Ensure that in deliveries to the customer only the agreed parts are included, for example production code without tests or vice versa - depending on the contract.
  • * Make it easily possible to handle test code differently in tools (for example, test coverage tools, static code analysis tools), for example by excluding them by path or module name or the like. The possibility to exclude them during normal compilation (with the `#[cfg(test)]` annotation as was mentioned by @Moshi) is just one example for this.
  • * Especially in contexts where different kinds of tests have to be performed (unit-tests, integration tests, performance tests, ...) it may become a practical necessity to have the different kinds of code clearly separated and individually structured to avoid confusion even during development. You may need to make additional distinctions between short running and long running tests and so on.
  • By grouping tests into a separated module or directory etc. you can fulfill the aforementioned goals - in some cases you will even have to go beyond that and introduce further substructuring.
  • When you think about how to organize your test code, you should develop an understanding of your goals. Typical goals about test code organization (which typically includes helper code only needed for the tests) are:
  • * Ensure that test code does not become part of production code - for some kinds of software this can even be a strict requirement (for example in safety critical software) - even if the test code within the production code would be dead code or unreachable.
  • * Ensure that in deliveries to the customer only the agreed parts are included, for example production code without tests or vice versa - depending on the contract.
  • * Make it easily possible to handle test code differently in tools (for example, test coverage tools, static code analysis tools), for example by excluding them by path or module name or the like. The possibility to exclude them during normal compilation (which the `#[cfg(test)]` annotation achieves, as was mentioned by @Moshi) is just one example for this.
  • * Especially in contexts where different kinds of tests have to be performed (unit-tests, integration tests, performance tests, ...) it may become a practical necessity to have the different kinds of code clearly separated and individually structured to avoid confusion even during development. You may need to make additional distinctions between short running and long running tests and so on.
  • By grouping tests into a separated module or directory etc. you can fulfill the aforementioned goals - in some cases you will even have to go beyond that and introduce further substructuring.
#3: Post edited by user avatar Dirk Herrmann‭ · 2023-06-10T07:47:14Z (over 1 year ago)
  • When you think about how to organize your test code, you should develop an understanding of your goals. Typical goals about test code organization (which typically includes helper code only needed for the tests) are:
  • * Ensure that test code does not become part of production code - for some kinds of software this can even be a strict requirement (for example in safety critical software) - even if the test code within the production code would be dead code or unreachable.
  • * Ensure that in deliveries to the customer only the agreed parts are included, for example production code without tests or vice versa - depending on the contract.
  • * Make it easily possible to handle test code differently in tools (for example, test coverage tools, static code analysis tools), for example by excluding them by path or module name or the like.
  • * Especially in contexts where different kinds of tests have to be performed (unit-tests, integration tests, performance tests, ...) it may become a practical necessity to have the different kinds of code clearly separated and individually structured to avoid confusion even during development. You may need to make additional distinctions between short running and long running tests and so on.
  • By grouping tests into a separated module or directory etc. you can fulfill the aforementioned goals - in some cases you will even have to go beyond that and introduce further substructuring.
  • When you think about how to organize your test code, you should develop an understanding of your goals. Typical goals about test code organization (which typically includes helper code only needed for the tests) are:
  • * Ensure that test code does not become part of production code - for some kinds of software this can even be a strict requirement (for example in safety critical software) - even if the test code within the production code would be dead code or unreachable.
  • * Ensure that in deliveries to the customer only the agreed parts are included, for example production code without tests or vice versa - depending on the contract.
  • * Make it easily possible to handle test code differently in tools (for example, test coverage tools, static code analysis tools), for example by excluding them by path or module name or the like. The possibility to exclude them during normal compilation (with the `#[cfg(test)]` annotation as was mentioned by @Moshi) is just one example for this.
  • * Especially in contexts where different kinds of tests have to be performed (unit-tests, integration tests, performance tests, ...) it may become a practical necessity to have the different kinds of code clearly separated and individually structured to avoid confusion even during development. You may need to make additional distinctions between short running and long running tests and so on.
  • By grouping tests into a separated module or directory etc. you can fulfill the aforementioned goals - in some cases you will even have to go beyond that and introduce further substructuring.
#2: Post edited by user avatar Dirk Herrmann‭ · 2023-06-10T07:34:08Z (over 1 year ago)
  • When you think about how to organize your test code, you should develop an understand of your goals. Typical goals about test code organization (which typically includes helper code only needed for the tests) are:
  • * Ensure that test code does not become part of production code - for some kinds of software this can even be a strict requirement (for example in safety critical software) - even if the test code within the production code would be dead code or unreachable.
  • * Ensure that in deliveries to the customer only the agreed parts are included, for example production code without tests or vice versa - depending on the contract.
  • * Make it easily possible to handle test code differently in tools (for example, test coverage tools, static code analysis tools), for example by excluding them by path or module name or the like.
  • * Especially in contexts where different kinds of tests have to be performed (unit-tests, integration tests, performance tests, ...) it may become a practical necessity to have the different kinds of code clearly separated and individually structured to avoid confusion even during development. You may need to make additional distinctions between short running and long running tests and so on.
  • By grouping tests into a separated module or directory etc. you can fulfill the aforementioned goals - in some cases you will even have to go beyond that and introduce further substructuring.
  • When you think about how to organize your test code, you should develop an understanding of your goals. Typical goals about test code organization (which typically includes helper code only needed for the tests) are:
  • * Ensure that test code does not become part of production code - for some kinds of software this can even be a strict requirement (for example in safety critical software) - even if the test code within the production code would be dead code or unreachable.
  • * Ensure that in deliveries to the customer only the agreed parts are included, for example production code without tests or vice versa - depending on the contract.
  • * Make it easily possible to handle test code differently in tools (for example, test coverage tools, static code analysis tools), for example by excluding them by path or module name or the like.
  • * Especially in contexts where different kinds of tests have to be performed (unit-tests, integration tests, performance tests, ...) it may become a practical necessity to have the different kinds of code clearly separated and individually structured to avoid confusion even during development. You may need to make additional distinctions between short running and long running tests and so on.
  • By grouping tests into a separated module or directory etc. you can fulfill the aforementioned goals - in some cases you will even have to go beyond that and introduce further substructuring.
#1: Initial revision by user avatar Dirk Herrmann‭ · 2023-06-10T07:33:53Z (over 1 year ago)
When you think about how to organize your test code, you should develop an understand of your goals.  Typical goals about test code organization (which typically includes helper code only needed for the tests) are:

* Ensure that test code does not become part of production code - for some kinds of software this can even be a strict requirement (for example in safety critical software) - even if the test code within the production code would be dead code or unreachable.

* Ensure that in deliveries to the customer only the agreed parts are included, for example production code without tests or vice versa - depending on the contract.

* Make it easily possible to handle test code differently in tools (for example, test coverage tools, static code analysis tools), for example by excluding them by path or module name or the like.

* Especially in contexts where different kinds of tests have to be performed (unit-tests, integration tests, performance tests, ...) it may become a practical necessity to have the different kinds of code clearly separated and individually structured to avoid confusion even during development.  You may need to make additional distinctions between short running and long running tests and so on.

By grouping tests into a separated module or directory etc. you can fulfill the aforementioned goals - in some cases you will even have to go beyond that and introduce further substructuring.