Melt half the butter in a frying pan and sauté the onions until golden brown. Add the mushrooms and sauté until the juices evaporate. Season with salt and pepper and add the sherry. Toss over high heat until the sherry evaporates. Set aside.
Cook the beans in salted water until just tender. Drain.
Add the remaining butter to the mushroom mixture and heat. Add the beans and toss with the stock until the vegetables are heated through and the mixture is dry. Transfer to a serving dish and serve at once.