Comments (3)
Hi Mark
Unity currently supports memory leak detection by abstracting malloc, etc. You can find this in the extras directory.
As I sidenote: It's not a feature we spend a lot of time promoting because memory leak detection is rarely a good fit with unit testing. It's a common paradigm for a particular unit to produce memory while another unit consumes it. Testing of real-world memory handling can be handled much more effectively with mocking if you're insisting on doing it in Unit Testing... but I'd really recommend doing it in higher level tests as well (system testing, etc). You are going to want to know if your entire application leaks memory and checking individual unit tests isn't as likely to catch such a thing.
I find that memory leak detection is one of the features that a lot of Unit Tests list (including this one) because it's easy to implement, but it's really not used often because it's the wrong fit.
Just an observation. ;)
Mark
from unity.
Thanks for the insights. Just to make sure I got it all... Are you saying one should not use unity for higher level tests? Which tools are you recommending?
Is that all I have to do to activate the feature, or do I need additional asserts etc.?
#include "unity_fixture_malloc_overrides.h"
from unity.
You need to use all of the unity_fixtures extras. The actual implementation of the memory overrides is in the unity_fixture.c module, which unfortunately means you have to take it all. If I remember correctly, there is also a bit of a challenge making sure that unity_fixture_malloc_overrides.h gets included even from the src module to override the malloc calls.
The memory tools should be split out from the fixture extension, since they aren't REALLY dependent on each other... just stuck in the same C module at this point.
Anyway, I use Unity for all the unit and interaction testing I do. For system testing I usually end up spinning my own framework using Ruby and Arduino for hardware interaction. The memory leak detection stuff, when dynamic memory is required, is a tricky one to fit in. I usually try to bake it into my release code itself, then check it during system tests. This might be more overhead than your application can support, which would suggest that you might want to do one of two things:
- break system testing into two levels... one that runs code WITH extras like memory leak detection turned on, and another which is your actual release code
- create high-level integration tests where you are combining multiple C modules together in order to properly support memory tests (you'd need all the modules that create or consume the memory). This is back to being a good fit for Unit Testing (and therefore Unity). The challenge of integration tests (no matter what framework) is that they can start to pull in a lot of mock/stub interfaces. It's doable, but might be more challenging than you hope.
Mark
from unity.
Related Issues (20)
- Intent of verbosity and command line parsing? HOT 6
- Bug: Boolean is found to be both true and false simultaneously HOT 3
- No mention about instructions to build from source and support_double option HOT 5
- mistakenly opened issue
- closed HOT 1
- Issue with comparing the streams. HOT 2
- Possibly typo in test_unity_integers_64.c and test_unity_arrays.c HOT 1
- Avoid running the setup for some specific tests HOT 3
- #529 still unfixed after merge HOT 2
- PlatformIO failing to parse manifest on install.
- Game thing.com HOT 1
- How do I rename the `setUp` and `tearDown` functions? HOT 2
- Build fails with -Werror=missing-declarations when UNITY_USE_COMMAND_LINE_ARGS is enabled HOT 1
- XML/JSON based report generating? HOT 2
- Errr how u use this HOT 1
- Can you code on iPad using this app?
- I'm in secondary school first grade sooo i have no idea what I'm doing (I'm trying to tell but not expose my age) HOT 1
- Can you use this app to code on iPad?
- ssize_t asserts are missing
- Add Example for Testing using CMake
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unity.