The test measures biological markers in urine created by the breakdown of foods such as red meat, chicken, fish and fruit and vegetables.
The test, developed by researchers from Imperial College London, Newcastle University and Aberystwyth University in the UK, also gives an indication of how much fat, sugar, fibre and protein a person has eaten.
The team hopes that with future development the test will be able to track patients' diets. It could even be used in weight loss programmes to monitor food intake.
"A major weakness in all nutrition and diet studies is that we have no true measure of what people eat," said Professor Gary Frost from Imperial.
Also Read
"We rely solely on people keeping logs of their daily diets - but studies suggest around 60 per cent of people misreport what they eat to some extent. This test could be the first independent indicator of the quality of a person's diet-and what they are really eating," Frost said.
The volunteers strictly followed these diets for three days, throughout which the scientists collected urine samples in the morning, afternoon and evening.
The team then assessed the urine for hundreds of compounds, called metabolites, produced when certain foods are broken down in the body.
These included compounds that indicate red meat, chicken, fish, fruit and vegetables, as well as giving a picture of the amount of protein, fat, fibre and sugar eaten.
From this information, the researchers were able to develop a urine metabolite profile that indicated a healthy, balanced diet with a good intake of fruit and vegetables.
The idea is this 'healthy diet' profile could be compared to the diet profile from an individual's urine, to provide an instant indicator of whether they are eating healthily.
Scientists then tested the accuracy of the test on data from a previous study. This included 225 UK volunteers as well as 66 people from Denmark. All of the volunteers had provided urine samples, and kept information on their daily diets.
Disclaimer: No Business Standard Journalist was involved in creation of this content