That really depends on your timeframe and what you want out of it. If you need to get there quickly, there are flights. If you have a lot of time, like a couple of weeks, and want to see a lot places in both countries, you can piece together buses and trains, which will be more expensive and some will leave or arrive at very weird times. If you have a little bit of time and want to relax and see the countryside, you can book a train from Lisbon to Madrid, and from Madrid to Barcelona (that might be two parts, I'm not sure).
We took a flight with a local airline. It was easier and faster than using the Renfe site, it was direct, and I think it was either cheaper or about the same price as the train (we would have gotten berths for sleeping).
I definitely prefer the calming pace of the train, seeing the scenery, and even bundling my hotel and travel if it's an overnight trip. And having several hours in a city in the middle is nice- an extra city to see. But we didn't have the time for any of that, so a flight it was. On a train you can also get up an move around a bit very easily, and I feel that that's more conducive to meeting people, if you're interested in meeting other travelers.
This was two years ago, btw, and we did our booking from the US. about 4 years ago