Spawning
Bats will spawn in large caverns. They can also be spawned with their spawn egg. Bats may spawn in an unlit house if its interior is large enough.
On superflat worlds, Bats have been observed to spawn in even 1x1 spaces that are unlit, such as in mob traps, possibly because the code that spawns them cannot find any other place to spawn them. This indicates that Bats do not require a large cave to spawn, but large areas do have a much higher chance of causing them to spawn. Bats will not spawn on glass or slabs, but could spawn randomly in your world if the light level is low enough and the Bat doesn't have enough spawning space.
The Minecraft Wiki is very helpful!