A simple $20 voltmeter will give a reasonably good indication, especially if the batteries have never been used. A lead acid battery should quiescently show 2.0 volts per cell. If the cells have failed, they readily show less than 1.0 volts per cell. For other battery technologies, other voltages apply.
Looking through my UPSs, it seems some use 12 volt batteries (6 cells in a case) and 24 volts (12 cells). The one which has been sitting unused for over a year is a 12 volt and shows 11.3 volts. That would indicate it is in fair condition, but certainly not new (I recall the charge controller had issues, not the battery).
A simple voltage test is far from conclusive. Rather it is equivalent to taking your temperature to see if you are sick. Temperature doesn't show all cases of sickness, but it is more than useful enough as first diagnostic.
For a more thorough battery test, a suitable battery load tester is useful. While inexpensive load testers are sold for car batteries, those use far too large a load for a UPS battery. Something in the 2 to 10 amp range would be more suitable, unless it is a mainframe-class UPS. You could MacGyver a small load, like a car headlamp in tandem with the voltmeter. Look at the battery voltage, enable the load. The voltage should drop a little, like 5% to 15%. A weak battery's voltage will plunge more than 30%.