You'd be forgiven for thinking that this is a picture of some sort of tomato. It's actually black nightshade, a close relative of tomatoes, potatoes and many other commonly eaten plants. It's also a close relative of deadly nightshade and is fairly similar in appearance.
DO NOT MIX THE TWO UP.
Don't rely just on my picture here as an ID aid, do some detailed research until you are 100% certain about this species. Black nightsjade berries grow in clusters (as pictured) whereas deadly nightshade berries grow singly but are also black.
The black nightshade berries can be eaten raw on their own and in salads like tomatoes or as an ingredient in pies and puddings.