I have a ZF2 application that I've setup to be built using a Makefile with various options. The issue at hand is that the /vendors/ directory can contain an assortment of dependencies that are installed/updated via composer. Each dependency may, or may not contain unit tests, and the location of the tests are arbitrary.
When make test is run, I would like the Makefile to search through the /vendors/ directory for any folders named /tests/ and perform unit testing accordingly.
What would be the most optimal way to iterate through the vendors and locate any /tests/ directories to be able to perform unit testing?
Use the wildcard function:
LIST_OF_TESTS:=$(wildcard vendors/*/tests)
Related
I have a tests directory containing several tests packages. I want to see if I am able to have a central main_test.go file which executes all tests packages internally?
This way I would be able to treat all packages as unified and be able to get a unified coverage report etc, without being worried about test setup or without adding any bash scripting etc.
I would like to ensure that a number of PDE target platform definitions are sound and would like to run these tests in a CI loop. I am aware that the director can be used to perform installations, but I would like to use the target files directly. How is this best done?
I am using CMake with Unix Makefile generator. When I use add_custom_target it generates the make target only in the CMAKE_CURRENT_BINARY_DIR and the CMAKE_BINARY_DIR.
I found it out by testing it with different layouts of sub-directories.
Is this somewhere documented? Is there a way to create a custom target that works in every target, similar to built-in make clean?
The rationale behind the question: I have a bunch of unit tests in several unittest folders. I don't build them with target all as compiling the tests takes much longer compared to the actual library. With the target unittest I can build them. I would like to be able to call this from every unittest subfolder. Preferably it would only build the unit tests located in the current directory and recursively in its sub-directories.
I have two unit test projects in my VS 2010 solution. Each project has a Data directory with input data needed for the unit tests.
I annotated the test classes that need the data with
[DeploymentItem("Data")]
When I run tests individually, the run fine. However, when I run (or debug) all tests in the solution, I find that only one of the two Data directories is copied to TestResults\MyTestDir-YYYY-MM-DD HH_mm_SS\Out, causing unit tests that rely on the other data directory to fail.
Interestingly if I then use the Test Results window to re-run checked (as in failed) tests, the tests still fail (they do not recognize that the correct Data directory's files are missing). If I then navigate directly to a failed test and select Run Tests in Current Context, the test run gets the correct Data directory and the test succeeds.
My question: How can I cause DeploymentItems from two separate test projects all to be copied to the Out directory where the tests are executed?
For reference, I have reviewed these questions without noting a solution
Problems with DeploymentItem attribute
Do MSTest deployment items only work when present in the project test settings file?
I found that giving each "Data" directory a unique name (e.g. "TestProjectAData") resolved the issue. There seems to be some sort of bug when multiple directories in different paths all have the same relative path to different test projects (i.e. if every test project has a subdirectory called "Data").
I know there is no right or wrong answer to this but it would be VERY helpful to see how others have structured their test projects? Especially for multi assembly solutions and managing different test phases, unit, integration, system?
And ontop of it all it would be helpful to see what structure fits nicely for running test builds on a Continuous Integration Server (TeamCity)?
Initially I am starting out with:
Test (Namespace)
--Unit (Folder)
----ClassATests
----ClassBTests
--Integration (Folder)
----ClassA+BTests
----DBTests
I've been thinking about this very thing at work today. I've inherited a test project that has been maintained and updated by multiple people in the past, and as such currently contains a rather confusing hierarchy.
In an attempt to simplify matters, I have started out using the following structure:
Tests (Namespace)
-- Infrastructure (Folder)
---- general utility classes (common to all tests)
---- any other config
-- ClassATests (Folder)
---- ClassATestBase (base class for setup of common mock objects etc.)
---- ClassATestMethods (helper methods for the ClassATests)
---- ClassATests (main test class)
-- ClassBTests (Folder)
etc.
I've found this approach to useful so far, as it means most of the code that will run during any given test can be found in the same folder. It also aims to avoid the scenario of one huge TestMethods class.
This may not be the most elegant of solutions (sorry, no pun intended!), but its working for me at present. Any and all suggestions are most welcome though!
I keep my unit tests and integration tests in separate assemblies (x.Tests.dll, y.IntegrationTests.dll) in order to be able to easily find test assemblies to run during the build process. I can then just locate *.Tests.dll and run them as part of a daily build. Integration tests are run manually in specific environments, but can still be run from a simple build script.
Apart from that, TestClass-per-Class is pretty much the rule I've followed with the exception being small helper classes that are all tested from a single HelperTests fixture.