exclude

ScalaTest 109: Mark your tests with tags to include or exclude them

Problem: You want a way to label your individual ScalaTest unit tests, so you can easily choose to include or exclude them when running your test suite. For instance, you may want to tag long-running tests like database or web service tests, because they take a long time to run, and you don’t want to run them all the time.

Solution

Create one or more custom tags, then include those tags in your test specifications. When you run your tests, declare which tests you want to run, or not run.

An Ant 'exclude classes' example

Problem: You want to build your Java project using Ant but you need to be able to skip certain files -- typically unit test files -- during the compilation or deployment processes.

Solution: You can skip files during the Ant compilation process by using the Ant exclude pattern. Here's an example that shows several exclude patterns in some XML code taken directly from an Ant build script:

How to exclude certain elements in an array with pattern matching

Problem: You have an array of elements, and you need to process every element in the array, except the elements that match a given regular expression (pattern).

Solution: You can solve this problem using a combination of the Perl regular expression pattern matching, along with the next operator.