Skip to content

Instantly share code, notes, and snippets.

@juven
Last active December 18, 2015 16:39
Show Gist options
  • Save juven/5812769 to your computer and use it in GitHub Desktop.
Save juven/5812769 to your computer and use it in GitHub Desktop.
puts "METHOD,CASE,DESCRIPTION,PRE,SCENARIO,PRIORITY"
basedir = ARGV[0]
def get_tag_value(tag, file)
File.open(file, 'r') do |f|
f.each do |line|
pattern = Regexp.new("(^\\*+ +)(#{tag}) ([^\\r\\n]*)")
begin
if line =~ pattern
return pattern.match(line)[3]
end
rescue ArgumentError => e
#puts e.message
end
end
""
end
end
Dir.glob("#{basedir}/**/*.java") do |file|
basename = File.basename(file, ".java")
if basename =~ /.*_.*_.*$/
test_method = basename.split('_')[0]
test_case = basename.split('_')[1]
test_description = basename.split('_')[2]
tag_pre = get_tag_value("@pre", file)
tag_scenario = get_tag_value('@scenario', file)
tag_priority = get_tag_value("@priority", file)
puts "#{test_method},#{test_case},#{test_description},#{tag_pre},#{tag_scenario},#{tag_priority}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment