find for specific content in file in the directory and list only file names

Hi,

I am trying to find the content of file using grep and find command and list only the file names

but i am getting entire file list of files in the directory

find . -exec grep "test" {} \; -ls

Can anyone of you correct this

find . -type f -exec grep -l "test" {} /dev/null \;

or

find . -type f | xargs grep -l "test"

Both commands are working fine. Thanks