Testing will only work if it's a non dietary cause, such as kidney or liver problems, mass, infection, abnormality of the bowel, stuff like that. But if you are thinking it's dietary, best way to find out is eliminating possible offending foods from the diet. This way you should be able to determine which is the problem food. Though if it doesn't seem to be dietary, definitely get tests done.
Common culprits are ones Blue eyes mentioned, but other things to consider are veggies that have started to go bad can cause upset, hay that has mold in it or weeds, some buns can be sensitive to certain types of hay such as rich early growth leafy hay, pellets that have gone bad or a new batch that might be contaminated in some way. I would first look at if anything new was started just prior to all of this happening. A new veggie added, a veggie fresh from the store possibly sprayed with a chlorine wash or something to help it stay fresh, a new bag of pellets opened up, a new bag or bale of hay, anything new added to the environment, if your rabbit is let outdoors it can be all sorts of things from outside.
If you think it's the veggies you can either go about eliminating one at a time or stop all veggies for a week or two to make sure the veggies are the culprit and he's doing good with no signs of upset, then gradually add them back in slowly one at a time. I would probably go for stopping all veggies then adding back in, just so you know for sure if it's the veggies or not, and so if it is that you don't have to deal with another upset stomach so soon after the last one. When you do start adding veg back in, I would do so very gradually, one at a time, and giving it a week or more of very gradually increasing, watching for any sign of upset soon after feeding. If he seems ok with that one veg being gradually increased after a week or so, then try adding in a new veg.