With the shrinking feature size and the growing density, testing neighborhood pattern-sensitive faults (NPSFs) of integrated circuits is more and more important, especially testing NPSFs of semiconductor memories. This paper presents a test algorithm for detecting the active NPSFs (ANPSFs) in ternary content addressable memories (TCAMs). Due to the special TCAM cell structure, unique test algorithm with only march-based test operations or only two-group test operations is not efficient. We propose a test methodology with both march-based and two-group tests to cover 100% ANPSFs in TCAMs. The total test complexity is 156N for an NtimesK-bit TCAM. Also, no TCAM circuit modification is needed to support the proposed test methodology