There are two things that Teva Pharmaceutical Industries (TEVA) and Amazon (AMZN -1.64%) have in common. They've both been investments that Warren Buffett's Berkshire Hathaway held in its portfolio (Amazon is a current holding while Teva was recently sold) , and they both outperformed the S&P 500 during the Great Recession, which began nearly 15 years ago. While the index fell by 38% during that time, the healthcare company climbed 10% in value, and the tech giant's 8% decline was modest by comparison.

If a recession does take place over the next year, could these stocks again prove to be good options to invest in? Let's see.

1. Teva Pharmaceutical

Teva provides patients with generic medications that are much cheaper than brand-name drugs. As patents expire on drugs, that paves the way for companies like Teva to bring cheaper products to market.

One example is AbbVie's rheumatoid arthritis medicine, Humira, which faces patent expiration next year. Teva has a biosimilar product, adalimumab, which could be one of many competitors to enter the market in 2023. And while competition from other generic drugmakers is fierce, Teva's adjusted gross margins have steadily been above 50% over the past few years.

But it hasn't been a smooth ride for the stock. While Teva outperformed the markets 15 years ago, that hasn't been the case of late. Teva has lost 77% of its value in the past five years (while the S&P 500 is up 60% during that time frame). In 2017, the healthcare company recorded a mammoth goodwill impairment charge of $17 billion due to a more challenging U.S. generics market (i.e., its pricing power wasn't nearly as strong).

Plus, the company has been involved in opioid lawsuits, and for the period ended March 31, it incurred $1.1 billion in legal settlements and loss contingencies that resulted in a net loss of $952 million for the quarter on sales of $3.7 billion. And there could more legal expenses related to opioid claims as these recent expenses are only based on updated estimates on how much the company may need to pay out. Teva also notes that it "is frequently subject to litigation." 

What that all means is that Teva is a riskier stock today than it was during the Great Recession. Although it has outperformed the markets in 2022 (with a 3% decline versus an 18% drop in the S&P 500), given its legal challenges and lack of consistent profitability, it's not a stock worth taking a chance on right now.

2. Amazon

It may be a surprise that Amazon did as well as it did during the Great Recession given that an economic downturn results in less disposable income and spending. However, with Amazon still in the early stages of its growth back then, the business was likely just doing too well for investors to be all that bearish on it.

In 2007, the company's net sales of $14.8 billion grew by 39%. And in a span of just three years, its top line had more than doubled. 

Today, however, it's a much different story. Amazon is a beast that over the trailing 12 months brought in $478 billion in sales. Although it's continuing to expand, it is much further along in its growth than it was 15 years ago. Amazon faces challenges today stemming from expanding too aggressively during the pandemic and potentially overestimating demand, which recently resulted in its first quarterly loss since 2015. 

Although the stock looks absurdly cheap over the long haul, in a recession, shares of Amazon could face significant pressure this time around. There are already cracks showing in its valuation with the tech stock declining 30% year to date. And even with the drop, its valuation remains elevated at close to 60 times earnings.

There's still some good value in the stock today, but investors shouldn't expect safety with the tech giant during a recession. If you can stomach what could be a rough year or two for the stock, then it could make for a solid investment to just buy and hold.